A man reported,

The Prophet ﷺ said, "When you arrive and the imam is bowing, then bow. If he is prostrating, then prostrate. But do not count the prostration if it was not preceded by bowing with him."

Azami 2338

Sahih

عن رجل

عن النبي ﷺ قال: إذا جئتم والإمام راكع فاركعوا، وإن كان ساجدا فاسجدوا، ولا تعتدوا بالسجود إذا لم يكن معه الركوع.

الأعظمي 2338صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Prayer
Chapter
Leadership
Section
If a man catches the imam in ruku, he has caught the rakat
Numbering
Jami al-Kamil 2338 (2nd edition)
Azami 2338