Intentions are the basis for the judgement of actions upon them
the Messenger of Allah ﷺ said, "Deeds are ˹judged based˺ by ˹their˺ intention, and a person ˹is granted the due˺ for what they intended. So whoever had emigrated ˹for the sake of˺ Allah and His Messenger then his emigration is ˹earned for the sake of˺ Allah and His Messenger; and whoever had emigrated for ˹the sake of˺ worldly benefits or for ˹the sake of˺ marrying a woman, the ˹due˺ of his emigration ˹is earned˺ for what he emigrated for."
قَالَ رَسُولُ اللَّهِ ﷺ «إِنَّمَا الأَعْمَالُ بِالنِّيَّةِ وَإِنَّمَا لاِمْرِئٍ مَا نَوَى۔ فَمَنْ كَانَتْ هِجْرَتُهُ إِلَى اللَّهِ وَرَسُولِهِ، فَهِجْرَتُهُ إِلَى اللَّهِ وَرَسُولِهِ؛ وَمَنْ كَانَتْ هِجْرَتُهُ لِدُنْيَا يُصِيبُهَا أَوِ امْرَأَةٍ يَتَزَوَّجُهَا، فَهِجْرَتُهُ إِلَى مَا هَاجَرَ إِلَيْهِ۔»