Pep didn't do anything wrong, that doesn't mean it was the right or logical decision though. It was very unfortunate and nobody could have envisaged it happening, but you ran the risk as soon as you decided to select a player that clearly had one foot out the door, despite Bayern not having made an official offer. People can turn a blind eye to that and be completely naive, like they were being in the summer, but it's clear the offer was coming once they had sorted everything with the player - which they allegedly had.
If it was the start of the league campaign rather than a glorified friendly I'd have more sympathy, but playing him has seemingly put us ~£50m out of pocket, which as I said in my original comment, would have gone a long way to have paid for a CB alone (not to mention the change for a replacement) and Sane leaving would have opened up a foreign spot, meaning we wouldn't have been stuck over signing Maguire at CB.