Mishkat al-Masabih 1155
وَعَن يَزِيدَ بْنِ عَامِرٍ قَالَ: جِئْتُ رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ وَهُوَ فِي الصَّلَاةِ فَجَلَسْتُ وَلَمْ أَدْخُلْ مَعَهُمْ فِي الصَّلَاةِ فَلَمَّا انْصَرَفَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ رَآنِي جَالِسا فَقَالَ: «ألم تسلم يَا زيد؟» قُلْتُ: بَلَى يَا رَسُولَ اللَّهِ قَدْ أَسْلَمْتُ. قَالَ: «وَمَا مَنَعَكَ أَنْ تَدْخُلَ مَعَ النَّاسِ فِي صَلَاتِهِمْ؟» قَالَ: إِنِّي كُنْتُ قَدْ صَلَّيْتُ فِي مَنْزِلِي أَحْسَبُ أَنْ قَدْ صَلَّيْتُمْ. فَقَالَ: «إِذَا جِئْتَ الصَّلَاةَ فَوَجَدْتَ النَّاسَ فَصَلِّ مَعَهُمْ وَإِنْ كُنْتَ قَدْ صَلَّيْتَ تَكُنْ لَكَ نَافِلَةً وَهَذِه مَكْتُوبَة» . رَوَاهُ أَبُو دَاوُد
From Yazid ibn ʿAmir, who said: I came to the Messenger of Allah ﷺ while he was in prayer, and I sat down and did not join them in the prayer. When the Messenger of Allah ﷺ finished, he saw me sitting and said: "Have you not accepted Islam, O Yazid?" I said: "Yes indeed, O Messenger of Allah, I have accepted Islam." He said: "Then what prevented you from joining the people in their prayer?" He said: "I had already prayed in my house, thinking that you had already prayed." He said: "When you come to the prayer and find the people [praying], pray with them, even if you have already prayed. It will be a voluntary prayer for you, and this one the obligatory one." Reported by Abu Dawud.