I’m assuming that you’ve taken her to her pediatrician to make sure that she doesn’t have a physical issue. If you haven’t, please do. Not everything is psychological.
If she is medically okay, then we look at psychological issues. Young children often regress when they are under stress. This little girl is dealing with rejection by her parents and a major change in her life. She may be trying to exert some control in her own life by trying to control her bladder. This is primitive behavior but not uncommon in stressed kids.
It’s notable that she did okay when she was only with you. It may be that she is adjusting okay to her home situation but the stress of a new school, new kids in her life, and the expectations of school are just too much for her.
I think you should start by just asking her. Tell her that sometimes kids go back to acting younger than they are when they are upset. Ask her how she feels about school. Are there any problems there you can help her with? Tell her you know it is hard on a kid when the grown ups are making all the decisions and she has so little say. But emphasize, as you already have, that you do love her and that you want to help her feel more comfortable.
Don’t make a big issue of the wetting. Just quietly help her clean up and put the soiled clothes in the laundry. Tell her you know she’ll be able to be more grown up when she is ready. The less said, the better. Give this approach an honest try — perhaps a month or so. If it doesn’t work, I do suggest that you get a consultation with a family therapist to help you all make this transition.
I wish you well.