Imam Malik, may Allah have mercy on him, said: If a person performs the prayer alone and then finds the prayer being performed with the Imam, there is no harm in performing it again, except for the Maghrib prayer, because if it is performed again, it will not remain odd, rather three will become two units.
It is narrated from Nafi that Sayyiduna Abdullah bin Umar (may Allah be pleased with them) used to say that whoever has performed the Maghrib or Fajr prayer, and then finds the congregation for these two prayers, should not repeat them.
Hadith Referenceموطا امام مالك رواية يحييٰ / كتاب صلاة الجماعة / 299
Hadith Gradingمحدثین:موقوف صحيح
Hadith Takhrij«موقوف صحيح، وأخرجه عبد الرزاق فى «مصنفه» برقم: 3939، 3940، وابن أبى شيبة فى «مصنفه» برقم: 6726، والطحاوي فى «شرح معاني الآثار» برقم: 2147، والبيهقي فى «معرفة السنن والآثار» برقم:1073، والشافعي فى الاُم برقم: 206/7، والشافعي فى المسند: 240/1، شركة الحروف نمبر: 281، فواد عبدالباقي نمبر: 8 - كِتَابُ صَلَاةِ الْجَمَاعَةِ-ح: 12»