I was present with the Prophet ﷺ during his pilgrimage and prayed the dawn prayer with him at the Mosque of Khayf. When he finished his prayer and turned, 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 them, "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 mosque where the congregation is praying, pray with them, for it will count as a voluntary prayer for you."
حدثنا أحمد بن منيع حدثنا هشيم أخبرنا يعلى بن عطاء حدثنا
شهدت مع النبي ﷺ حجته فصليت معه صلاة الصبح في مسجد الخيف قال فلما قضى صلاته وانحرف إذا هو برجلين في أخرى القوم لم يصليا معه فقال علي بهما فجيء بهما ترعد فرائصهما فقال ما منعكما أن تصليا معنا فقالا يا رسول الله إنا كنا قد صلينا في رحالنا قال فلا تفعلا إذا صليتما في رحالكما ثم أتيتما مسجد جماعة فصليا معهم فإنها لكما نافلة
[Its chain of transmission is sahih] Nasai narrated it (2/112, 113, no. 859) through Hushaym with the same wording, and Ibn Khuzayma graded it sahih (no. 1279), as did Ibn Hibban (no. 434, 435). Abu Dawud narrated it (no. 575, 576, no. 856) and others narrated the hadith of Yaala bin Ata with the same wording, and it has a corroborating narration in Nasai.