Our Gemara on Amud Beis discusses the ethical and characterological problem of flattering sinners:

וְאָמַר רַבִּי אֶלְעָזָר: כׇּל אָדָם שֶׁיֵּשׁ בּוֹ חֲנוּפָּה — אֲפִילּוּ עוּבָּרִין שֶׁבִּמְעֵי אִמָּן מְקַלְּלִין אוֹתוֹ, 

And Rabbi Elazar says: Any person who has flattery in him, even fetuses in their mothers’ wombs curse him, 

This is a strange expression.  I think it is fair to say that most people are not too concerned with  what fetuses think of them. This idiom is also used by Sanhedrin (91b) to discourage a different unethical behavior:

 אמר רבי שמעון חסידא כל המונע הלכה מפי תלמיד אפילו עוברין שבמעי אמו מקללין אותו 

Rav Ḥana bar Bizna says that Rabbi Shimon Ḥasida says: With regard to anyone who withholds halakha from being studied by the mouth of a student who seeks to study Torah, even fetuses in their mother’s womb curse him.

Is there a connection to these two traits, and is there an explanation as to why this arouses contempt of fetuses in particular? The Maharal (Nesivos Olam, Nesiv Torah 9:4) suggests that fetuses are unborn potential, and similarly a teacher who withholds information from a student is leaving him incomplete. Likewise, we can say approving of a sinner’s delusion and immoral beliefs leaves him in an unformed state. Ben Yehoyada on this daf says that even fetuses, who are not yet under the social contract and have no obligation to rebuke, are disgusted with the  craven behavior of the flatterer. That does not explain the teaching in Sanhedrin, however the Chida (Maris Ha’ayin on Sanhedrin) explains that even the fetuses who study Torah in the womb, though not obligated, have contempt for this teacher who doesn’t teach.

The Peshat that seems most compelling to me is from the Sefas Emes (Vayikra, Pesach 17), which is stated in regard to yet another teaching about fetuses.  We saw in Sotah (31a-b) that the fetuses sang Az Yashir at the Red Sea. Sefas Emes says this expresses a transgenerational effect. The experience at the Red Sea led to an echo and recognition of this miracle throughout the generations. So too, if the teacher withholds halakhic guidance or a person flatters a sinner, there is a loss that reverberates through the generations. This is what it means when it says that even the fetuses curse him.