Yazid bin Aswad reported,

He prayed with the Messenger of Allah ﷺ when he was a young lad. After the prayer ended, he noticed two men in a corner of the mosque who had not prayed. The Prophet ﷺ called for them, and they were brought to him trembling.He asked, "What kept you from praying with us?"They replied, "We had already prayed at our lodgings."He said, "Do not do that. When one of you prays at his lodging and then comes upon the imam before he has prayed again, let him pray with the imam, for it will count as a voluntary prayer for him."

Abu Dawud 575

Sahih

حدثنا حفص بن عمر حدثنا شعبة أخبرني يعلى بن عطاء

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

أنه صلى مع رسول الله ﷺ وهو غلام شاب فلما صلى إذا رجلان لم يصليا في ناحية المسجد فدعا بهما فجئ بهما ترعد فرائصهما فقال ما منعكما أن تصليا معنا قالا قد صلينا في رحالنا فقال لا تفعلوا إذا صلى أحدكم في رحله ثم أدرك الإمام ولم يصل فليصل معه فإنها له نافلة

أبو داود 575صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Abu Dawud
Book
Prayer
Chapter
One who prays at home then catches the congregation and prays with them
Numbering
Darussalam 575
Abu Dawud 575