The World Federation One Stop Fiqh

Ruling 1430

If while a person is performing a three rakʿah or four rakʿah prayer a congregational prayer commences, in the event that the congregational prayer is for the same prayer that the person is performing, and he has not gone into the rukūʿ of the third rakʿah and he is not confident that if he completes the prayer he will be able to join the congregational prayer, it is recommended that he complete the prayer as a two rakʿah prayer with the intention of a recommended prayer and join the congregational prayer.