I will re post a post of mine on occasions of sin.
Occasions of sin…
There are all sorts of* remote occasions of sin* in life…all sorts of possible good things that one can do --where there is a possibility that some temptation may come. We would have to lock avoid many good things in life to avoid all those --and maybe knock ourselves unconscious…
(not saying here one does not still seek to avoid such often…one judges prudently such things…it can be quite good to “flee temptation”.)
(And there are things of the area where “lust” can happen that are to be avoided in themselves).
Certainly though one is to avoid the near occasion of mortal sin.
We are obliged to avoid near occasions of mortal sin (usually more the focus is on such in this sort of question).
What though is a near occasion of mortal sin?
It is not simply temptation (though let us seek to avoid temptations).
A near occasion of mortal sin is such where one would generally falls into mortal sin -one generally commits a mortal sin (or even always!)–or is what is likely to cause one to commit a particular mortal sin now. Due to the nature of thing itself (things leading to lust are often of this sort) or ones particular weakness (but can be of this sort).
Though there can at times be good reasons to be in them…ones confessor can guide one (necessary occasions…which one still tries to make more remote…)
Those are the general principles for one to apply. *Ones confessor can guide one. * In specifics.
Temptation, occasions of sin and near occasions are treated for what they are. Let us calmly but with due haste -avoid deliberate sins and what lead to them -especially mortal sins - and turn to the Lord.
I will note too that there can be times when one knows there could be a possibility of “indirect sexual pleasure” (not wanted or sought) happening (without sin) -where one there is a good reason for the action and such is not sought or consent to if it happens. The person would not intend or seek or consent to such. One must use prudence and chasity and modesty to guide one (one might judge to change the action for example). Discuss with your confessor these things.