Anas was asked about the garlic; he stated that the Messenger of Allah ﷺ had said: He who eats of this plant (garlic) should not approach us and pray along with us.
قَالَ رَسُولُ اللَّهِ ﷺ مَنْ أَكَلَ مِنْ هَذِهِ الشَّجَرَةِ فَلاَ يَقْرَبَنَّا وَلاَ يُصَلِّي مَعَنَا