The Messenger of Allah ﷺ said, "Whoever takes an oath and then sees something better than it, let him do what is better and abandon his oath."
حدثنا بهز حدثنا شعبة أخبرني عبد العزيز بن رفيع قال سمعت تميم بن طرفة الطائي يحدث
قال رسول الله ﷺ من حلف على يمين فرأى غيرها خيرا منها فليأت الذي هو خير وليترك يمينه
Its isnad is sahih, mentioned previously at 18167.