Shaykh Muḥammad ibn Sāliḥ al-ʿUthaymīn

If crying in the prayer is due to the fear of Allah ﷻ or a person remembers some of the promises and admonitions that have been mentioned in the Noble Qurʾān, then this does not invalidate the prayer. However, if the crying is a result of remembering some misfortune that has befallen or something similar, then this invalidates the prayer.

This is because something external has occurred in the prayer. It is obligatory upon him to prevent himself from this type of crying so that he is not subjected to invalidating his prayer. It has been legislated upon him not to be concerned with anything that is not connected to the prayer. He should not think about other matters since thinking about matters that are not connected to the prayer greatly decrease the reward of the prayer.