It is related in the Sahih, on the authority of Abu Hurayrah (may Allah be pleased with him), that the Messenger of Allah ﷺ said: “Be keen on what benefits you, seek help from Allah, and do not be incapacitated. If something befalls you, do not say, ‘Had I done such-and-such, such-and-such would have happened.’ Rather say, ‘Allah decreed it, and whatever He wills, He does,’ for the word ‘if only’ opens the door to the work of Satan.” (1)
—
In the Sahih: that is, in Sahih Muslim.
Be keen (iḥris): ḥirṣ is to exert effort and deploy one’s full capacity.
On what benefits you: meaning, in both your worldly life and your Hereafter.
Seek help from Allah: aid in all your affairs comes from Allah alone, not from anyone else.
Do not be incapacitated (wa-lā taʿjazan): whether the middle consonant is read with kasrah or fatḥah, the sense is: do not neglect the pursuit of what benefits you by leaning on destiny and surrendering to weakness and laziness.
If something befalls you: that is, if a matter overpowers you and the intended result is not achieved despite your effort and ability,
then do not say, “Had I done such-and-such …,” for such words bring you no benefit.
Rather say, “It is Allah’s decree,” for whatever He decrees must inevitably occur, and one is obliged to submit to what has been ordained.
For “if only” opens the door to Satan’s activity, because it involves regret over what has already passed.