Pray two Rak'ah when you enter the masjid before sitting down
It was narrated from Abu Hurairah that the Messenger of Allah (sallallaahu alayhi wa sallam) said:
"When anyone of you enters the mosque, let him not sit down until he performs two Rak'ah."
[Sunan Ibn Maajah Hadiith No. 1065]
Based on the above hadiith all of the Jurists agree that it is makruuh to sit down before praying two Rak'ah.
What if a person comes and sits down before he prays the two Rak'ah. Does he get up and pray them or has he missed them?
According to a group of scholars it is a Sunnah to get up and pray them based on the following narration
Jabir bin 'Abdullah reported:
Sulaik Ghatafani came on Friday when the Messenger of Allah (sallallaahu alayhi wa sallam) was delivering the sermon. He (Sulaik) sat down. He (the Holy Prophet) said to him: O Sulaik stand and observe two rak'ahs and make them short, and then said: When any one of you comes on Friday, while the Imam delivers the sermon, he should observe two rak'ahs and should make them short.
[Sahiih Muslim Hadiith No. 875]
He sat down. He was commanded to get up and offer two Rak'ah.
The scholars of the Shaafi'i school claim that the one who sits has missed them and cannot get up to pray them.
Kuwaiti Encyclopedia of Fiqh
Volume 15 Page 265