Yazid bin Aswad reported,

I was present with the Prophet ﷺ during his Hajj, and I prayed the dawn prayer with him in the Mosque of Khayf. When he finished his prayer and turned around, he saw 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.He asked, "What kept you from praying with us?"They replied, "Messenger of Allah ﷺ, we had already prayed in our camp."He said, "Do not do that. If you have prayed in your camp and then come to a congregational mosque, pray with them, for it will count as a voluntary prayer for you."

Azami 2359

Sahih

عن جابر بن يزيد بن الأسود الخزاعي، عن أبيه، قال

شهدت مع النبي ﷺ حجته، فصليت معه صلاة الصبح في مسجد الخيف، قال: فلما قضى صلاته وانحرف إذا هو برجلين في أخرى القوم لم يصليا معه، فقال: علي بهما فجيء بهما ترعد فرائضهما فقال: ما منعكما أن تصليا معنا؟ فقالا: يارسول الله ﷺ إنا كنا قد صلينا في رحالنا. قال: فلا تفعلا، إذا صليتما في رحالكما، ثم أتيتما مسجد جماعة، فصليا معهم؛ فإنها لكما نافلة.

الأعظمي 2359صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Prayer
Chapter
Congregational prayer
Section
One who prays alone then finds a congregation and prays with them
Numbering
Jami al-Kamil 2359 (2nd edition)
Azami 2359