This issue was in the local news recently. Ontario and Quebec (and possibly other provinces) house inmates based on their sex. Trans inmates are categorized based on whether they've undergone bottom surgery, which is already a somewhat arbitrary line. Recently there's a woman who's met that criteria and Ontario corrections have been challenging her transfer request.
I know the history of segregated women's prisons are intertwined with asylums, which were often used to imprison women for all manner of things I don't know if women's prisons were introduced before the closure of most asylums, but I think they were.
I'm glad your friend got out. I hope life on the outside is kind to him ️🩹