The Prophet ﷺ said, "Come to the prayer with calmness and dignity. Pray whatever you catch with the imam, and make up whatever you missed."
حدثنا محمد بن جعفر حدثنا شعبة عن سعد بن إبراهيم قال سمعت أبا سلمة يحدث
عن النبي ﷺ أنه قال ائتوا الصلاة وعليكم السكينة فصلوا ما أدركتم واقضوا ما سبقكم
Its chain of transmission is sahih. The leading scholars narrated it with similar wording, Bukhari 1/163 in the chapter on the adhan, on a man's saying, "We have missed the prayer," Muslim 2/420 no. 602 in the chapters on masjids, on the recommendation of approaching the prayer with dignity, Abu Dawud 1/157 no. 573 with wording matching Ahmad, in the chapter on prayer, on hastening to the prayer, Tirmidhi 2/149 no. 327 in the chapter on prayer, on what has been said about walking to the masjid, Ibn Majah 775, Nasai 2/114, Darimi 1/294, Abdul-Razzaq 3102 and 3404, and Ibn Abu Shayba 2/358.