Mishkat al-Masabih 1155
Yazid b. ‘Amir said:
I came to God’s Messenger when he was praying and sat down, but did not join the congregation in prayer. When he finished he saw me sitting and asked, “Have you not become a Muslim, Yazid?” I replied, “I certainly have become a Muslim, Messenger of God.” He asked, “What prevented you from joining the people in their prayer?” I replied, “I had already prayed at home, thinking you had prayed.” So he said, “When you come to prayer and find the people praying, pray along with them. If you have already prayed it will be a supererogatory prayer for you, though this is a prescribed prayer.” 

Abu Dawud transmitted it.
وَعَن يَزِيدَ بْنِ عَامِرٍ قَالَ: جِئْتُ رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ وَهُوَ فِي الصَّلَاةِ فَجَلَسْتُ وَلَمْ أَدْخُلْ مَعَهُمْ فِي الصَّلَاةِ فَلَمَّا انْصَرَفَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ رَآنِي جَالِسا فَقَالَ: «ألم تسلم يَا زيد؟» قُلْتُ: بَلَى يَا رَسُولَ اللَّهِ قَدْ أَسْلَمْتُ. قَالَ: «وَمَا مَنَعَكَ أَنْ تَدْخُلَ مَعَ النَّاسِ فِي صَلَاتِهِمْ؟» قَالَ: إِنِّي كُنْتُ قَدْ صَلَّيْتُ فِي مَنْزِلِي أَحْسَبُ أَنْ قَدْ صَلَّيْتُمْ. فَقَالَ: «إِذَا جِئْتَ الصَّلَاةَ فَوَجَدْتَ النَّاسَ فَصَلِّ مَعَهُمْ وَإِنْ كُنْتَ قَدْ صَلَّيْتَ تَكُنْ لَكَ نَافِلَةً وَهَذِه مَكْتُوبَة» . رَوَاهُ أَبُو دَاوُد