عَنْ عَلِيٍّ وَمُعَاذِ بْنِ جَبَلٍ رَضِيَ اللَّهُ عَنْهُمَا قَالَا: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «إِذَا أَتَى أَحَدُكُمْ الصَّلَاةَ وَالْإِمَامُ عَلَى حَالٍ فَلْيَصْنَعْ كَمَا يَصْنَعُ الْإِمَامُ» . رَوَاهُ التِّرْمِذِيُّ وَقَالَ: هَذَا حَدِيثٌ غَرِيبٌ
Translation

Abu Huraira reported God’s Messenger as saying, “When you come to the prayer and we are prostrating ourselves you must prostrate yourselves without reckoning it as part of your prayer; and if anyone is present at a rak'a he has been present at the prayer.” Abu Dawud transmitted it.