أحسن الله إليكم What if someone enters the mosque and sees that congregation is praying ʿIshāʾ, while he still has to pray Maghrib? Should he pray alone or with congregation? And how should he pray if he arrives on time, and if he joins in the second rakʿah? Jazak Allahu khayran

Ustadh AbdulAziz al-Haqqan
He should pray with them. However, at his third rak'ah, he finishes his salah. He sits for the last tahiyyat, finishes his salah, and then stands up to join Isha with them. He says, "Allahu Akbar," joins the congregation, and then continues what he has missed from Salatul Isha. However, we must advise the brother not to miss the time for Maghrib unless it is a dire situation beyond his control that led him to do so.