Is entering the masjid after eating raw onions completely prohibited and sinful (haram) or only makrooh (disliked) ?
Hadith in Sahih Muslim 564c states:
"Jabir b. 'Abdullah reported the Messenger of Allah (ﷺ) saying:
He who eats of this (offensive) plant, i. e garlic, and sometimes he said: He who eats onion and garlic and leek, should not approach our mosque for the angels are harmed by the same things as the children of Adam."
With regard to the validity of prayer when there is an unpleasant smell in the mouth, it is valid but it is makrooh (disliked).
If the prayer is offered in the mosque and this smell is obvious to such an extent that it annoys other worshippers and the angels, then it is haraam. Al-Bukhaari (806) and Muslim (870) narrated that the Prophet (peace and blessings of Allaah be upon him) said: “Whoever has eaten of this plant (i.e., garlic), let him not approach our mosque.”