Sunan Abi Dawud, Book 2, Hadith 577 (USC-MSA) ⓘ
Narrated Yazid ibn Amir: I came while the Prophet was saying the prayer. I sat down and did not pray along with them. The Messenger of Allah turned towards us and saw that Yazid was sitting there. He said: Did you not embrace Islam, Yazid? He replied: Why not, Messenger of Allah; I have embraced Islam. He said: What prevented you from saying prayer along with the people? He replied: I have already prayed in my house, and I thought that you had prayed (in congregation). He said: When you come to pray (in the mosque) and find the people praying, then you should pray along with them, though you have already prayed. This will be a supererogatory prayer for you and that will be counted as obligatory.
حَدَّثَنَا قُتَيْبَةُ، حَدَّثَنَا مَعْنُ بْنُ عِيسَى، عَنْ سَعِيدِ بْنِ السَّائِبِ، عَنْ نُوحِ بْنِ صَعْصَعَةَ، عَنْ يَزِيدَ بْنِ عَامِرٍ، قَالَ جِئْتُ وَالنَّبِيُّ صلى الله عليه وسلم فِي الصَّلاَةِ فَجَلَسْتُ وَلَمْ أَدْخُلْ مَعَهُمْ فِي الصَّلاَةِ - قَالَ - فَانْصَرَفَ عَلَيْنَا رَسُولُ اللَّهِ صلى الله عليه وسلم فَرَأَى يَزِيدَ جَالِسًا فَقَالَ " أَلَمْ تُسْلِمْ يَا يَزِيدُ " . قَالَ بَلَى يَا رَسُولَ اللَّهِ قَدْ أَسْلَمْتُ . قَالَ " فَمَا مَنَعَكَ أَنْ تَدْخُلَ مَعَ النَّاسِ فِي صَلاَتِهِمْ " . قَالَ إِنِّي كُنْتُ قَدْ صَلَّيْتُ فِي مَنْزِلِي وَأَنَا أَحْسِبُ أَنْ قَدْ صَلَّيْتُمْ . فَقَالَ " إِذَا جِئْتَ إِلَى الصَّلاَةِ فَوَجَدْتَ النَّاسَ فَصَلِّ مَعَهُمْ وَإِنْ كُنْتَ قَدْ صَلَّيْتَ تَكُنْ لَكَ نَافِلَةً وَهَذِهِ مَكْتُوبَةً " .
also referenced under: Hadith 577 (DarusSalam) & Hadith 577 (Hasan)