Yahya related to me from Malik from Nafi that Abdullah ibn Umar used to say, "Someone who prays maghrib or subh and then catches them with the imam should not repeat them." Malik said, "I do not see any harm in someone who has already prayed in his house praying with the imam, except for maghrib, because if he repeats it, he makes it even."
أَنَّ عَبْدَ اللَّهِ بْنَ عُمَرَ كَانَ يَقُولُ مَنْ صَلَّى الْمَغْرِبَ أَوِ الصُّبْحَ ثُمَّ أَدْرَكَهُمَا مَعَ الإِمَامِ فَلاَ يَعُدْ لَهُمَا قَالَ مَالِكٌ وَلاَ أَرَى بَأْسًا أَنْ يُصَلِّيَ مَعَ الإِمَامِ مَنْ كَانَ قَدْ صَلَّى فِي بَيْتِهِ إِلاَّ صَلاَةَ الْمَغْرِبِ فَإِنَّهُ إِذَا أَعَادَهَا كَانَتْ شَفْعًا