https://abukhadeejah.com/a-man-enters-mosque-imam-is-praying-isha-but-he-hasnt-prayed-maghrib/
A man enters the mosque, and the ‘Ishā prayer is being prayed — but this man has not yet prayed Maghrib due to a valid excuse — so what does he do? (Shaikh Al-Albānī)