بسم الله الرحمن الرحيم
Q: Some people if they enter the masjid close to the time of the congregation prayer [i.e. the iqaama is close and prayer will begin soon] they stay standing waiting for the Imaam to arrive and abandon the 2 units of prayer for the greeting of the masjid [tahiyyatul Masjid], so what is the ruling upon that?
A: If the time period is short from the point of his arrival to the congregational prayer starting and would not suffice for the 2 raka’at of tahiyyatul masjid then there is no harm standing and waiting momentarily for the Imam to arrive since it is imminent. However, if they do not know when the Imaam will arrive then it is superior to pray the 2 units of tahiyyatul masjid, and even if the Imaam arrives and the Iqaama is done for the prayer to start and you are still in your first raka’at of the tahiyyatul masjid then you may cut the prayer off to join the congregation, however if you are in your second raka’at then complete it lightly [i.e. do not elongate it, rather pray it short] and join them.
[Based on Fataawa Arkaan ul-Islam Shaikh ibn ul-Uthaymeen p309]