Abu Hurairah reported the Messenger of Allah ﷺ as saying; when you come to pray while we are prostrating ourselves, you must prostrate yourselves, and do not reckon it anything (rak’ah) he has been present at the prayer. (Using translation from Abū Dāʾūd 893)
قَالَ رَسُولُ اللَّهِ ﷺ «إِذَا جِئْتُمْ وَنَحْنُ سُجُودٌ فَاسْجُدُوا وَلَا تَعُدُّوهَا شَيْئًا وَمَنْ أَدْرَكَ رَكْعَةً فَقَدْ أَدْرَكَ الصَّلَاةَ»