I was present with the Messenger of Allah ﷺ for the dawn prayer at Masjid al-Khayf. When he had finished his prayer, he noticed two men at the back of the gathering who had not prayed with him. He said, "Bring them to me."They were brought forward, trembling with fear.He asked, "What kept you from praying with us?"They replied, "Messenger of Allah, we had already prayed at our camp."He said, "Do not do that. If you have prayed at your camp and then come to a congregational mosque, pray with them. It will count as a voluntary prayer for you."
أخبرنا زياد بن أيوب قال حدثنا هشيم قال حدثنا يعلى بن عطاء قال حدثنا
شهدت مع رسول الله ﷺ صلاة الفجر في مسجد الخيف فلما قضى صلاته إذا هو برجلين في آخر القوم لم يصليا معه قال علي بهما فأتي بهما ترعد فرائصهما فقال ما منعكما أن تصليا معنا قالا يا رسول الله إنا قد صلينا في رحالنا قال فلا تفعلا إذا صليتما في رحالكما ثم أتيتما مسجد جماعة فصليا معهم فإنها لكما نافلة
[Its chain of transmission is sahih] Tirmidhi transmitted it, Prayer, chapter on what has been said about a man who prays alone and then joins the congregation, no. 219, from the hadith of Hushaym with this wording, and he said, "Hasan sahih." It is also found in Kubra, no. 931. Ibn Khuzayma graded it sahih, no. 1279, as did Ibn Hibban, no. 434, 435. It has corroborating narrations, see the preceding hadith. Abu Dawud also transmitted it, no. 575, 576, from the hadith of Yaala with similar wording.