There are two idioms involved here:
We went to dinner (at the pub). Our friends came to dinner here.
We went (to the pub) for dinner. We had our friends over for dinner.
So which idiom you use depends on what your cousin actually did. If she came in order to have dinner with you, use for. If she just joined you at the pub to enjoy your intellectually superior conversation, use to.
Formally, if you use the for construction it should be attached to dinner rather than pub:
We went for dinner, for which my cousin came along, at a nearby pub.
But conversation is not so exacting. And in fact, colloquially, what I've given you here are more ‘as-a-rule’ or ‘rule-of-thumb’ than Rules. Nobody will raise an eyebrow, or even notice, if you say “We had our friends over to dinner” or “We went to the pub to dinner”, any more than they'll snigger at your ending a sentence with a preposition. You often start a sentence going in one direction and end up going in another, and in conversation you don't get to go back and rewrite the beginning. You can of course in a email; but nobody† does. Nobody cares.
† Well, I do; but I’m a professional writer and have a reputation to prop up.