The rules of insider trading are complicated. You might think it's as simple as "don't trade on nonpublic information you got from an insider," but it isn't. There are strange and subtle rules about how you can get that information, about what sorts of benefits to the insider, or friendship between you and the insider, that make his tips and your trading illegal. The rules are even more complex for traders who get their tips indirectly; there, the inquiry involves not only what benefit the insider got, but also what the traders knew about it.
But there is a rough useful metarule, which is that if your interactions with the insider look corrupt, that's bad. For instance if you hand him a sack of cash in a parking lot, you have to know you're going to prison. Similarly don't do this: