Sahih Muslim 648 c
Narration text is preserved in its supplied Arabic and English. Translated interfaces and reading guides do not add narration translations in other languages.
فَإِنْ أَدْرَكْتَ الْقَوْمَ وَقَدْ صَلَّوْا كُنْتَ قَدْ أَحْرَزْتَ صَلاَتَكَ وَإِلاَّ كَانَتْ لَكَ نَافِلَةً "
Abu Dharr reported:
My friend (the Holy Prophet) bade me to hear and obey (the ruler) even if he is a slave having his feet and arms cut off, and observe prayer at its prescribed time. (And further said): It you find people having observed the prayer, you in fact saved your prayer, otherwise (if you join with them) that would be a Nafl prayer for you.
Full reference and source
Sahih Muslim 648 c In-book : Book 5, Hadith 303 USC-MSA web (English) : Book 4, Hadith 1355 (deprecated)
View source on Sunnah.com (opens in a new tab)