This is because the Messenger ﷺ said, “Do not initiate the Jews or the Christians with the greeting of peace.” Yet if you fear some harm from him, you may restrict yourself to the single word al-salām.
The scholars—may Allah have mercy on them—have differed over whether one may open the conversation with non-Muslims using formulas other than salām, such as marḥaban (“greetings”), or ahlan wa-sahlan (“welcome”).
• Some held it permissible, as a way of winning hearts, especially when one fears the person or is uncertain of his intentions.
• Others ruled it impermissible, arguing that such expressions confer undue honor upon him.
In practice, whether one says marḥaban, ahlan, and the like depends on whatever necessity or benefit the situation requires.
The author then cites the ḥadīth concerning a person who passes by a gathering that includes both Muslims and non-Muslims: should he omit the greeting because unbelievers are present, or extend it because Muslims are present? Here two considerations coincide—one permitting and one forbidding. The permissive factor is the presence of Muslims; the prohibitive factor is the presence of non-Muslims.
Ordinarily, when a permissive and a prohibitive factor cannot be separated, the legal maxim dictates that the prohibitive side prevails and the act is avoided. In this case, however, separation is possible: one may pronounce the salām while intending it specifically for the Muslims. This was the practice of the Prophet ﷺ, for he once passed by a gathering that contained idolaters, Jews, and also Muslims, and he offered them the greeting of peace.
Allah alone grants success.