The obvious retort is that most managers spend all day tossing ot off in their offices anyway.
TBH he went to the right place for the task. I supose the issue was he should have been in a cubicle. So was it an indecent exposure or lewed act issue.
In any case I bet there is nothing in the employers hanbook specifically relating to it.
Difficult one. If it were me and I had a factory of workers once I would not have sacked him. Fairly sure they would have left themsleves anyway out of embarrasment.