The couples I interviewed for my book, Two in a Bed, offered reasons for sleeping together and also reasons to sleep apart when one of the partners has the flu or a cold. I'm not a physician and don't have medical advice to offer you, but I can tell you what the people I interviewed said.
When you're around your positive friend you connect and relate to him or her. When you're around the miserable boss, you're tense because you're picking up on his tension, maybe even trying to understand him, and it doesn't make you feel good.
The good news is that stress isn't the only thing that's contagious; so is optimism, enthusiasm, positivity, and fun. If you want to feel good stuff reflected back at you, you've got to put something good out there to begin with.