How does a factory reset work on an iPhone?

I was using my ex girlfriends phone for a bit and I performed a factory reset when I gave it back to her.

When I checked the setting on my Apple ID on my new phone it said I was still logged on on that phone.

Now I'm having anxiety that all my text messages etc are still on that phone

If a factory reset is done correctly and the phone says "hello" does that mean everything is gone? Or is there still a chance she could have recovered everything

If you do a factory reset, then everything will be erased from the phone, hence the name "factory reset". That includes any accounts you have setup on the device. Try removing the old iPhone from iCloud through the iCloud Find my iPhone page.