The World Federation One Stop Fiqh

Ruling 1383

When congregational prayers are being performed, it is recommended that a person who has performed his prayers on his own perform them again with the congregation. If he later realises that his first prayer was invalid, his second prayer will suffice.