بسم الله الرحمن الرحيم
The Prophet (pbuh) said: “When any one of you comes for the Friday (prayer) and the Imam comes out (from his apartment), (even then) should observe two rak’ahs (of prayer).” [Muslim]
–
Most scholars have said that this refers to the greeting of the mosque prayer [tahiyyat al-masjid]. Imam Adil Salahi states:
“What is normally required when the imam delivers his speech is for all the people in the mosque to listen attentively to the sermon, trying to make the maximum benefit of it…
The question is whether the one arriving late, with the sermon in progress, should sit and listen, or should start by offering a prayer of two short rak’ahs in greeting to the mosque. Normally, we offer this short prayer at any time we come into the mosque. With the imam delivering his sermon, a special situation arises…
Since the greeting prayer is recommended, not compulsory, a late comer has the option of either sitting down on arrival to listen to the sermon, or to start by offering two short rak’ahs before sitting down.
Either alternative is good, because we are in worship from the moment we enter the mosque. If one sits down to listen, then one must not get up again to pray before the end of the sermon and the congregational Friday prayer is completed.” [Source]