"Teachers should engage their brains a bit more than they appear to be doing, and also their hearts."
Again I don't think it's always fair to blame an individual teacher. In many cases it's a school policy that is the issue and the teacher is caught between a rock and a hard place, wanting to do what they think is the right thing, but also wanting not to purposely break school policy!
I'm lucky in my job that there is no policy on this so I let any pupil go to the toilet that wants to. I think it is the right thing to do, and I have the luxury of well behaved kids - luckily I can trust most of them. Behaviour is great.
However in a previous job I remember all teachers being told by SLT that for Year 9 exam week pupils weren't allowed to go to the toilet during exams and only in the break. I was so unhappy with that rule and strongly disagreed with it. I brought it up with my line manager but has no impact. So I spent my whole time invigilating worrying that a pupil was going to want to go to the toilet and I was going to have to either disobey SLT's explicit instructions or say no, which I felt was morally wrong. Thankfully I didn't have to make that decision. But I don't think it's fair to always blame the teacher - it's often school leaders that are at fault... And they're often the ones with little actual contact time with the pupils (and the luxury of being able to go to the loo when they want!!).