The TVTropes Trope Finder is where you can come to ask questions like "Do we have this one?" and "What's the trope about...?" Trying to rediscover a long lost show or other medium but need a little help? Head to Media Finder and try your luck there. Want to propose a new trope? You should be over at the Trope Launch Pad.
That's close, but it feels like this'd be more of a separate subtrope of it. Using the example above, Bob's actions *have* resulted in something good, but Bob's initial intent was to just cause problems. He had no idea he'd end up doing something good. And in addition to that, all the other people involved end up being thankful rather than annoyed at him. Also this is played very straight: the audience is supposed to agree with everyone else, that Bob's actions resulted in good.
Basically it's an incredibly contrived coincidence that allows a "good" character to act like an asshole for a bit, but still end up as "good" in the eyes of both the other characters and the audience.
Edited by XStickman

This is a trope where a character is vindicated by circumstances entirely beyond anyone's knowledge or control, where character A can do something that is particularly assholish, but during this something happens that makes everyone thank character A, even though he had no idea about it.
The clearest example I can think of is this: Bob has a crush on Alice, but Alice is going on a date with John. John is a fantastic guy and Alice really likes him, but Bob goes along on the date specifically to ruin it. During Bob's shenanigans, John ends up revealing himself as a horrible person and Alice dumps him on the spot, and then thanks Bob for helping her out. Then everyone thinks Bob is a great guy, even though he (and everyone else) had no idea about John's true character, he just wanted to ruin the date out of spite.
It doesn't apply just to dates, though.