His statement, “If he knows of it but neither sees nor hears it, he has a choice,” means that he learns of the evil after attending. He may then choose between remaining and leaving, for he neither witnesses the evil nor hears it, and so he bears no sin. He may also leave as a disciplinary measure against those who committed the evil.
Which is preferable: that he leave or remain? The answer depends on what serves the greater interest. This choice is not one of personal inclination; rather, it is a choice determined by what serves the greater interest, since the aim is the welfare of others. Whenever the aim is the welfare of others, the choice is governed by what serves the greater interest, not by personal preference. Thus, if his leaving would deter them and others besides them, then without doubt he must leave. At times, however, remaining may be preferable, depending on the circumstances. For instance, if his leaving in that situation would result in severing family ties, then we may say that his remaining is preferable, since he neither saw nor heard it. Yet he should admonish, advise, and denounce the evil. If they do not respond, there is no harm in his remaining seated, because he is not among those committing the evil.
If this man is an eminent person—such as a scholar or a minister—whose departure will be noticed, and they regard it as one of the strongest forms of disciplinary rebuke, then he must leave, because doing so helps remove the evil. But if he is an ordinary person whose leaving or remaining would attract no attention, then we may say that he has a choice. Or we may say that, if he considers leaving better for his heart and more conducive to consciousness of his Lord, he should leave.
His statement, “If he knows of it”: if he merely suspects it but does not know, then the basic ruling is that he must accept the invitation. He should attend, and if his suspicion proves true, then if he is able to change it, he must change it; otherwise, he must leave.