Is it recommended for a person who has already prayed an obligatory prayer to repeat it if they join a congregation praying the same prayer during a prohibited time, provided they are in the mosque?
Chapter on the Times When Prayer is Prohibited
Al-Mughni
Book of Prayer
Primary text
It is recommended for the one who prayed his obligatory prayer (Fard) to repeat it in congregation if he joins them while the prayer is established and he is inside the mosque or enters while they are praying. This is the position of al-Hasan, al-Shafi'i, and Abu Thur. If the Fajr or Asr prayer is established while one is outside the mosque, it is not recommended for him to enter to join. The evidence for repetition being recommended comes from the Hadith of Jabir ibn Yazid ibn al-Asvad, where the Prophet (peace be upon him) commanded those who had prayed in their lodgings to pray again with the congregation, stating: "Pray with them; it shall be a supererogatory prayer (Nafl) for you." This general evidence applies to the repetition of Fajr and similarly Asr. Further evidence includes the Hadith of Busr ibn Mihjan's father, where the Prophet (peace be upon him) told him to pray with the people even if he had prayed at home, and the narration from Abu Dharr where the Prophet (peace be upon him) commanded: "If you overtake it with them, then pray, and do not say: I have already prayed, so I will not pray."
Supporting text
Malik stated that repetition is only for one who prayed alone; if prayed in congregation, there is no repetition, based on the narration mentioning 'we prayed in our lodgings.' Abu Hanifa argued that Fajr, Asr, and Maghrib should not be repeated because they are voluntary (Nafl) and prohibited during the prohibited times based on the general prohibition, and Maghrib should not be repeated because voluntary prayer should not be Witr (odd numbered). Ibn al-'Umar and al-Nakha'i held that all prayers should be repeated except Fajr and Maghrib. Abu Musa, Abu Mijlaz, Malik, al-Thawri, and al-Awza'i held that all should be repeated except Maghrib to avoid voluntary Witr. Al-Hakim stated that only Fajr should be excluded.