If a person joins when the imam is in qiyām of the third or fourth rakʿah, he must recite Sūrat al-Ḥamd and the other surah. If he does not have enough time to recite the other surah, he must complete Sūrat al-Ḥamd and join the imam in rukūʿ. If he does not have enough time to recite all of Sūrat al-Ḥamd, he can discontinue reciting Sūrat al-Ḥamd and go into rukūʿ with the imam.
However, the recommended precaution is that in this situation, he should make the intention of performing the prayer on his own and complete the prayer.