it is obligatory for an Imam who forgetfully rises up to offer a fifth Rak‘ah although the Ma’mums draw his attention and he is not sure himself, to respond to the Ma’mums. If the Imam intentionally continues offering the fifth Rak‘ah, his Salah and that of the Ma'mums who follow him in this will be Batil (null and void) if they know that it is a fifth Rak‘ah.
speaking intentionally renders the Salah Batil. Except for a forgetful or ignorant person; speaking in Salah does not nullify it in their case, according to the preponderant scholarly opinion. This is due to the Hadith narrated by
Mu‘awiyah ibn Al-Hakam that a man sneezed while offering Salah in congregation. Mu‘awiyah responded with "Yarhamuka Allah (May Allah have mercy on you)" but the Sahabah (Companions of the Prophet, may Allah be pleased with them) disapproved of what he did. When he concluded his Salah, he went to ask the Prophet (peace be upon him), who said:
“Truly, nothing of people’s talk is right during this Salah; it is only Tasbih (glorification of Allah), Takbir (magnification of Allah) and recitation of Qur’an.”
The Prophet (peace be upon him) did not order Mu‘awiyah to repeat his Salah. This shows that if the one who speaks in Salah is ignorant of the legal ruling, his Salah will be valid.
Also speaking in Salah for its interest does not nullify it. This is based on the Hadith of
Dhul-Yadayn. (Part No. 5; Page No. 436)
misses a Rak‘ah in a congregational Salah and the Imam mistakenly offers a fifth Rak‘ah, they should not consider this additional Rak‘ah and should make up for the Rak‘ah they missed.May Allah grant us success. May peace and blessings be upon our Prophet Muhammad, his family, and Companions.