I can't help you with rules, I'm afraid - it's more that it sometimes works and sometimes doesn't, in different combinations. That will come to you with experience, and an errant (or missing) i will never destroy your meaning, so there's no need to worry from an understanding point of view.
It may help to know that the i is attached to the previous word, and doesn't correspond to the "to" of "to walk" for instance. So, there's always an i after mynd (going to) - mynd i wylio, mynd i siarad, because that i is a moving "to". The same is true of the "dod" in your example. You're not moving anywhere with gobeithio, so gobeithio gweld, gobeithio mynd, gobeithio siarad.
I have a vague recollection of someone putting a list of "words that take the i" on the forum once, but I wouldn't recommend trying to learn a list. But at least now you can see every time the Welsh comes with or without an i that the pattern is in the word before. That should help you get a feel for what's right much more quickly.