When the Messenger of Allah ﷺ returned from the expedition of Tabuk and drew near to Medina, he said, "In Medina there are people who were with you in every march you made and every valley you crossed."They asked, "Messenger of Allah, even though they were in Medina?"He replied, "Even though they were in Medina. A valid excuse kept them behind."
حدثنا ابن أبي عدي حدثنا حميد
لما رجع رسول الله ﷺ من غزوة تبوك فدنا من المدينة قال إن بالمدينة لقوما ما سرتم مسيرا ولا قطعتم واديا إلا كانوا معكم فيه قالوا يا رسول الله وهم بالمدينة قال وهم بالمدينة حبسهم العذر
Its chain of transmission is sahih. Bukhari related the hadith 6/10 in the book of military expeditions, Muslim 3/1518 no. 1911 in the book of leadership, chapter on the reward of one who is prevented by a valid excuse, Abu Dawud 3/12 no. 2508, and Ibn Majah 2/923 no. 2764.