The value of deeds is based on the intentions behind them
I heard ˹ʿUmar b. al-Khaṭṭāb ؓ˺ on the minbar (pulpit) and he said: I heard the Messenger of Allah ﷺ say, "Deeds are ˹judged based˺ upon ˹their˺ intentions, and every person ˹is granted the due˺ for what they intended. So whoever had emigrated for ˹the sake of˺ worldly benefits or for ˹the sake of˺ marrying a woman, then the ˹due˺ of his emigration ˹is earned for˺ or what he emigrated for."
سَمِعْتُ رَسُولَ اللَّهِ ﷺ يَقُولُ «إِنَّمَا الْأَعْمَالُ بِالنِّيَّاتِ، وَإِنَّمَا لِكُلِّ امْرِئٍ مَا نَوَى۔ فَمَنْ كَانَتْ هِجْرَتُهُ إِلَى دُنْيَا يُصِيبُهَا أَوْ إِلَى امْرَأَةٍ يَنْكِحُهَا، فَهِجْرَتُهُ إِلَى مَا هَاجَرَ إِلَيْهِ۔»