Leaving to fulfil a bodily necessity is allowed. It is not a blanket permission to spend extra time on unrelated errands. The person should return to the place of retreat once the need is complete.
Using a toilet and then remaining outside for a lengthy social visit are distinct acts; the exception covers the necessary task, not unrestricted delay.