Allāh تعالى says (what means):
“No calamity befalls (a person) except by the permission of Allāh, and whoever believes, Allāh guides his heart.”
[At-Taghābun:11]
Ibn ‘Abbās رضي الله عنه commented:
“Nothing happens except by the command of Allāh, His decree and His will. Allāh guides the heart of the one who believes to have certainty. Therefore, he knows that whatever has happened to him was not going to pass him by and whatever has passed him by was not going to happen.”
[Taken from the Tafsīr of Ibn Kathīr]