Mishkat al-Masabih 1
عَنْ عُمَرَ بْنِ الْخَطَّابِ رَضِيَ اللَّهُ عَنْهُ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «إِنَّمَا الْأَعْمَال بِالنِّيَّاتِ وَإِنَّمَا لكل امْرِئ مَا نَوَى فَمَنْ كَانَتْ هِجْرَتُهُ إِلَى اللَّهِ وَرَسُولِهِ فَهِجْرَتُهُ إِلَى اللَّهِ وَرَسُولِهِ وَمَنْ كَانَتْ هِجْرَتُهُ إِلَى دُنْيَا يُصِيبُهَا أَوِ امْرَأَةٍ يَتَزَوَّجُهَا فَهجرَته إِلَى مَا هَاجر إِلَيْهِ»
From ʿUmar ibn al-Khattab, may Allah be pleased with him, who said: The Messenger of Allah ﷺ said: "Actions are only by intentions, and each person has only what he intended. So whoever's emigration is to Allah and His Messenger, his emigration is to Allah and His Messenger; and whoever's emigration is for some worldly gain he will get or a woman he will marry, his emigration is to that for which he emigrated."