The Messenger of Allah ﷺ said, "Whoever takes an oath and then sees that something else is better than it, let him do what is better and offer expiation for his oath."
قال رسول الله ﷺ: من حلف على يمين، فرأى غيرها خيرا منها، فليأت الذي هو خير، وليكفر عن يمينه.
Nasai (3781), Ibn Majah (2111), and Ibn Hibban (4347) all narrated it from the hadith of Abdullah bin Amr. There is disagreement about it, for it was narrated from Hisham bin Urwa, from his father, from Abdullah bin Amr. It was also narrated from Amr bin Shuayb, from his father, from his grandfather. These versions strengthen one another and do not contradict each other. This is the pattern of a hasan hadith.Some scholars held this view and said that expiation may not be offered before the violation of the oath, and this is what Abu Hanifa and his companions held. Tirmidhi said, "Some scholars said that one should only make expiation after violating the oath. Sufyan Thawri said, if he makes expiation after violating the oath, that is more beloved to me, but if he makes expiation before violating the oath, it suffices him."