The Messenger of Allah ﷺ said, "Whoever is invited to a meal while fasting should accept the invitation. If he wishes, he may eat, and if he wishes, he may refrain."
قال رسول الله ﷺ: من دعي إلى طعام وهو صائم فليجب، فإن شاء طعم، وإن شاء ترك.
Ibn Majah (1751) narrated it from Ahmad bin Yusuf Sulami, who said, Abu Asim narrated to us, who said, Ibn Jurayj informed us, from Abu Zubayr, from Jabir, and he related it. Its chain of transmission is sahih.Muslim narrated it in the Book of Marriage (1430) through another route from Abu Asim, with his chain, and through two other routes from Sufyan, from Abu Zubayr, but he did not mention in it "fasting."It was also narrated by Abu Dawud (3740), Nasai in Al-Kubra (6610), Ibn Hibban (5303), and Bayhaqi (7/264), all of them through various routes from Abu Zubayr, and they did not mention in it "fasting."