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 performs them again with the congregation. And if he later realises that his first prayer was invalid, his second prayer will suffice.