For Sanji:
Because Oda is writing humans and not machines, characters don't evolve in the blink of a eye
Concerning Usopp, his entire characterization in One Piece revolves around the notion of courage. During Dressrosa, Usopp was pushed to his limits. Not only his courage was tested but his loyalty too. Because both of those things are linked.
By giving candy to people Sugar can erease memory of people. She is therefore the representation of what Usopp fear the most: losing his friends.
Now, in Dressora, Usopp courage was tested two times. First, by his loyalty: he was promised by the tontata to be a savior, but he denied that status by running away.. This is were the real development of Usopp appeared, Usopp turned back, his courage pushed him to face Sugar and the other guy head on.
Of course he was defeated, but that's not the point, the point is that he faced himself and just like water Seven with his pride, he made the right choice of loyalty out of courage.
This is the moment for you to understand that Usopp is a comedic character who is the representation of courage, but he is also the representation of fear. Just like Batman, Usopp defeats his ennemies with fear. So it's logical that the moment Usopp was nourrish with candy, he exulted with suffering in a way that would scare anyone. Sugar was therefore instantly frightened which permitted Usopp to win the first match despite himself.
Now come the second round. This time, Usopp courage is at his best and it's time for him to defeat his antagonist by his own means. That's the moment Oda chooses to make Usopp develop observation haki but that's also the peak moment of Usopp in term of skill in the entire story. And what did Oda choose to defeat Sugar a second time ? Fear. The same thing that was introduced a while ago. But this time Usopp is in control.
---
So to say that Usopp or Sanji are "pathetic" is a GREAT missunderstanding of the narration of One Piece during those arc and during the entire story in fact.
Oda is creating amazing humans, but he also has the ability to write in subtext. That's why you need to check deeper. One Piece is not just a simple shonen. Everything is thought with a narrative purpose. And just like a good ficiton, not everything is told to the reader. That's why you need to be careful at what is being showned.