It wasn't a useless game, Spain weren't yet guaranteed Pot 1 for the Euro 2024 groups.
Barcelona fucked up their squad management and haven't rested Gavi at all this year, if the injury is from overplaying then that's where the majority of the blame lies.
Manager who doesn't rotate his first XI when he has the option to is surprised when players get injured.