But this doesn’t seem to be a one off instance, as a number of players have also stated that this has too happened to them.
I assume this is that case because if a low level player was to try and take over the gym alongside a high level player, then the Ditto would destroy the low level player as even if Ditto was weak, as it would take the traits of the stronger Pokemon.
But this also may work in favour of team battles in general as one player could enter a gym with a strong Snorlax, while the other could enter it with a Rattata and so have the Ditto transform into the weaker Rattata.
Also another thing to take into account if you are attacking a gym with a Ditto, it seems as if that it only Transforms once even if you win and go over to the next Pokémon.
So there you have it, I hope that answered some questions about battling Ditto in gyms with a teammate, as there were so many unanswered questions about Ditto earlier this week.