All of them are fine.
There is no particular interaction of the choice of forms with a by expression.
The difference between had given and gave is that with had given, the speaker is choosing to view the event from some later point in the past. With gave, no particular temporal viewpoint (or "story time") is set or used.
So in 2, there is no "story time" set, and the narrative simply follows the events in order - first I give him the money, and then I go home.
In 5. had given is natural, because it is viewing the giving from a particular later time - the time when confirmed it. It's still not obligatory even in this case - we don't always use the past perfect when the temporal relationships are clear. But it's more natural.
In 3, had given makes clear that the time when (I realised) he wasn't pleased was later than the giving - if his displeasure was clear at the time of giving, I'd expect he hadn't been pleased.
In 1 and 4, the events are being viewed from the time when I went home - presumably around 6 o'clock.
Edit: I had (!) missed sentence 6. In 6, had vanished is normal, because you're looking at the event from the time when somebody (possibly) told you. Again, it's not obligatory: the temporal relationships are clear, so people would often user the simpler vanished. But had vanished is the most natural option here.