If Flick underestimated a team like Osasuna he deserve what he got, but it could be he was trying things out with those poor line ups of his, that caused his first time loss in laliga at El Sadar this season. Initially he may have thought they'll bounce back and win the game, but Osasuna outsmarted them by taking up their chances, and utilizing every opportunity.
Additionally, all four goals was as a result of Barca's defensive error, the goal keeper did his best, meaning that Flick should work further on his defenders, else other teams would operate on that loophole.
Flick didn't underestimated the Osasuna players, it's just that they were prepared ahead of time against Barcelona and one thing I noticed is about that game is that Osasuna didn't give Barcelona a breathing space to make a recovery. Immediately they score, they turn the game from offensive to defensive and when they notice Barcelona couldn't penetrate, they add another goal and the whole first half was hard for them to equalized.
In the second half early, they were able to equalized and Osasuna had to go back and to defend again but immediately they had opened opportunity, they add another 2 making 4 and they were now leading with goals to 1 and came back to defend again but they were tired of defending and Yamal saw that chance and lead the team with 2, there was no way they could score 2 matches in the remaining extra time and that's how the game ended.