The Messenger of Allah ﷺ said, "Whoever takes an oath and then sees that something else is better, let him do that which is better and make expiation for his oath."
حدثنا علي بن محمد وعبد الله بن عامر بن زرارة قالا حدثنا أبو بكر بن عياش عن عبد العزيز بن رفيع عن تميم بن طرفة
قال رسول الله ﷺ من حلف على يمين فرأى خيرا منها فليأت الذي هو خير وليكفر عن يمينه
Its chain of transmission was recorded by Muslim in the book of Oaths, the aforementioned chapter, hadith no. 1651, through another route from Abdul-Aziz, at greater length.