Hadith 1158
وَعَنْ نَافِعٍ قَالَ: إِنَّ عَبْدَ اللَّهِ بْنَ عُمَرَ كَانَ يَقُولُ: مَنْ صَلَّى الْمَغْرِبَ أَوِ الصُّبْحَ ثُمَّ أَدْرَكَهُمَا مَعَ الْإِمَامِ فَلَا يَعُدْ لَهما. رَوَاهُ مَالك
Nafi‘ said that Ibn ‘Umar used to say, “If anyone prays the sunset or the morning prayer and then comes when the imam is praying them, he must not say them over again.” Malik transmitted it.