How do they determine who wins when it times out?

I can’t figure it out.

I just had a match where we both lost 2 pokemon. He had a snorlax with 5% or so life, and I had a Cressila with 40%

And I got “Good Effort”

Other times, I have got the win. I don’t know how it figures that crap out.

I read somewhere that the game checks out how many pokemons each have left and how much HP. No idea really, ive never had a draw