قَالَ مَالِك : وَلَا أَرَى بَأْسًا أَنْ يُصَلِّيَ مَعَ الْإِمَامِ مَنْ كَانَ قَدْ صَلَّى فِي بَيْتِهِ إِلَّا صَلَاةَ الْمَغْرِبِ ، فَإِنَّهُ إِذَا أَعَادَهَا كَانَتْ شَفْعًا
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.