Umar bin Khattab reported,

The Prophet ﷺ said, "Actions are judged by intentions, and every person will have only what they intended. Whoever's migration was for the sake of Allah and His Messenger, his migration is to Allah and His Messenger. And whoever's migration was for some worldly gain he sought or a woman he wished to marry, his migration is to whatever he migrated for."

Nasai 3825

Sahih

أخبرنا إسحق بن إبراهيم قال أنبأنا سليمان بن حيان قال حدثنا يحيى بن سعيد عن محمد بن إبراهيم عن علقمة بن وقاص

عن عمر بن الخطاب

عن النبي ﷺ قال إنما الأعمال بالنية وإنما لامرئ ما نوى فمن كانت هجرته إلى الله ورسوله فهجرته إلى الله ورسوله ومن كانت هجرته لدنيا يصيبها أو امرأة يتزوجها فهجرته إلى ما هاجر إليه

النسائي 3825صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Nasai Sughra
Book
Oaths and vows
Chapter
Intention in oaths
Numbering
Darussalam 3825
Nasai 3825