A legal contract is only as strong as the incentives to litigate it. Doesn't seem likely a contract would've helped, it may even have existed.
Yes, landlord reasonably checked out. They agreed on terms in terms of the monthly amount, utilities etc. New roommate gave some reason to want to get going on getting their stuff moved in or measuring things or something, she gave them a copy of the key for that.
That's all it took.
Regardless, tough lesson to learn on not handing out a key to someone without a contract. I mean, that's a level of trust that I don't even have with my friends, much less someone I'm potentially going to room with. No contract, no keys.
I had a feeling there was more to the story. There probably still is, but I'm satisfied now on how this managed to "just happen". I still don't understand how, after the restraining order, this person then claimed legal residence in order to get your friend removed from her legal residence. I also don't understand why this wasn't immediately a phone call to the police to get this person removed from the property.
Did she even bother to draft a contract with the subletter? Or was this all just, "sure, stranger, move right on in to the property for which I am legally obligated? I'm sure this will all work out fine."