Upon offering the Maghrib prayer, the Imaam stood up for a fourth Rak‘ah and we notified him (by saying Subhaan Allaah) but he went on. Then, all of us prayed the fourth Rak‘ah with him and we prostrated twice after the Salaam. Is our prayer valid?
All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
If the Imaam stood up to offer an additional Rak‘ah, those praying behind him have to say ‘Subhaan Allaah’ loudly so as to notify him. However, if he resumed the additional one, then they must not follow him as they know that it is additional. Any deliberate addition to the prayer nullifies it.
We hope that your prayer is valid because you were unaware of this ruling, as well you are not obliged to make it up.
However, it would be better for you to make it up so as to stay away from the difference in opinions pertaining to this ruling. As for the Imaam, if he did not recognize the notification of those praying behind him, then his prayer is valid.
Allaah Knows best.
You can search for fatwa through many choices