It was narrated from Abu Hurairah that the Prophet (ﷺ) said: “If anyone of you is invited to eat when he is fasting, let him say: ‘I am fasting.’”
It was narrated from Jabir that the Messenger of Allah (ﷺ) said: “Whoever is invited to eat when he is fasting, let him accept the invitation; and if he wants to let him eat, and if he wants let him not eat.”