Appropriate Joy
Shulchan Aruch (529:3) writes, "One should eat, drink, and be joyous on Yom Tov, but the focus should not be on the meat, wine, laughter, and lightheadedness, as they are not true joy. They are levity and foolishness. We are not obligated to engage in silliness and foolishness, but rather in the joy of serving Hashem."
The Rambam (Hilchos Lulav 8:14) writes, "The dancing at the simchas beis hashoeivah [in the Beis HaMikdash] wasn't performed by amei ha'aretz or by whoever wanted to dance. Only the gedolim, chachmei Yisrael, roshei yeshivos, the heads of the Sanhedrin, chassidim, elders, and anshei ma'aseh were worthy to dance there. They danced, clapped their hands, played music, and were happy in the Beis HaMikdash during Succos, and the rest of the nation, the men and the women, came to watch and listen."
The Ritva (Bava Basra 121.) explains that the average person wasn't permitted to dance and perform stunts. This was to ensure that the joy remained holy and that it didn't turn into הוללות, levity.
Sfas Emes zt'l suggests that this concept is hinted at in the word 'אך' from the verse והיית אך שמח. The Torah instructs us והיית אך שמח to be exceedingly joyful, but with limitations. Not all forms of happiness are beneficial. We should only seek the joy that will result in a connection with Hashem.24
24. People sing ושמחת בחגיך והיית אך שמח with a tune that repeats the word אך several times. Bederech tzachus, Reb Yosef Chaim Sonnenfeld zt'l said that this is based on the Chazal, אין מיעוט אחר מיעוט אלא לרבות that whenever there is more than one מיעוט limitation, expressed in the Torah, it means that we should increase rather than decrease. Therefore, we repeat the word אך, to increase our joy, and not to decrease it. This reminds us to be extra happy on Yom Tov.
Or, it can be explained this way: אך is a מיעוט implying that we must know that even a tiny amount of joy is already a great accomplishment.
Another approach is that אך is a limitation, which refers to when things aren't going well for a person. The Torah instructs us היית אך שמח; even then, one must be happy.