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.
قَالَ رَسُولُ اللَّهِ ﷺ إِذَا جِئْتُمْ إِلَى الصَّلاَةِ وَنَحْنُ سُجُودٌ فَاسْجُدُوا وَلاَ تَعُدُّوهَا شَيْئًا وَمَنْ أَدْرَكَ الرَّكْعَةَ فَقَدْ أَدْرَكَ الصَّلاَةَ