Quoting my own personal heuristic for offensive jokes from a similar thread:
"here is my personal rule of thumb for offensive jokes
if the punchline of your joke is that an offensive situation or caricature is inherently funny, then you do not have a joke. i.e. an asian joke where the punchline is "lol asians have slanty eyes", a black joke where the punchline is "lol black people and their saggy pants", a joke about women where the punchline is "lol she got raped". you are not making a joke here, you are repeating a stereotype or hurtful situation as if it is inherently funny. this is mere regurgitation, the equivalent of comedic vomit
however, you can use offensive caricatures and situations in a joke to parody absurdity or make a larger point. for instance, key and peele have a skit about slavery where two black slaves up for auction who talked of how they refuse to be owned and will rebel so hard go on to become upset when they are passed up for what appear to be physically weaker slaves and insult the other slaves who were sold. the auctioneer acts haughtily apalled that they would say such rude things and then end the auction early. the two unsold slaves then take the fact that they were not sold as an insult and try to make sales pitches about themselves, finally resigning to "well i didn't want to be sold anyways". despite this skit being about an inherently offensive topic and having the potential to be taken the wrong way by shitty people to mean "lol look at these uppity blacks being mean to each other while the civilized white man disciplines them", this skit is funny because it subverts expectations and parodies an absurd situation. actual thought went into its construction, and it was funny before i explained it
basically, an offensive caricature or situation should not be treated as inherently funny, but can be used to construct a joke that is funny."