Experience. I was in the role of the teenager.
Yes, some jokes were okay, especially the toothless ones. Like, making a joke about being poorer or having worse quality of products than the West was relatively safer than making a joke about party members killing each other or hurting random people.
It also depended on who could hear you, and what kind of a job your parents had. The better job, the greater risk of losing your job for saying wrong stuff.
Also, "speak quite freely at home" is more than just jokes. I am pretty sure most people would not feel safe discussing The Gulag Archipelago at home.