Hmm, I would say it means: They just wanted Ted to be happy, and they didn't think that thing would happen if Mary was involved/if Mary was together with him/etc. "With" can have several meanings, so taken out of context it's difficult to guess. Just my opinion though.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.
CalifJimSo, as it stands, and in agreement with Kooyeen, I'd have to say that it means they didn't think Mary would be happy. In other words, they didn't think 'being happy' would happen in Mary's case.I read it as meaning that Ted won't be happy if he is with Mary.
RayHI read it as meaning that Ted won't be happy if he is with Mary.Hee! That works too.