The World Federation One Stop Fiqh

Ruling 1188

If a person has a doubt that invalidates prayers and he knows that if he continues to the next stage of the prayer he will either be certain or have a supposition [about the thing he is currently doubting], then in case his doubt arises in the first two rakʿahs of the prayer, it is not permitted for him to continue the prayer in the state of doubt. For example, if while standing he doubts whether he has performed one rakʿah or more and knows that if he goes into rukūʿ one of the possibilities of his doubt will become a certainty or a supposition, it is not permitted for him to perform rukūʿ in that state. As for all other doubts that invalidate prayers, one can continue the prayer until he becomes certain or has a supposition.