It is easy for us to laugh when we are happy because we feel much more comfortable.
More subjectively, our emotions also play a role in determining what we will find funny or not. Some emotions act as deterrents to our sense of humor. They almost prevent or block us from laughing. For example, when we feel angry, nervous, excluded, criticised, embarrassed and/or fearful, we tend not to find things humorous that we would otherwise. Fear is quite a common emotion that prevents us from letting out a loud "whoop!" We are scared of being perceived as strange or "oddballs." Also, who looks at their best when their mouth is wide open, with tears falling down their cheeks and are struggling to breathe?! Depending on how we perceive/experience the atmosphere in which the joke is told, we will be more or less willing to take a risk and chance looking like a fool!
And then there are the emotions that put us in "in the mood" for laughter. For example, happiness, merriment, cheerfulness, inclusion, acceptance, valuable and joviality can make us laugh, even at the silliest of things. Under the influence of these emotions, we feel good and positive about ourselves and the people around us. We feel comfortable and less apprehensive of taking risks. We want to laugh and nothing is gonna stop us! Heck, we'll even laugh at the weak jokes - why not? It doesn't hurt!