One of the things that I have tried to teach to anyone who reads this blog is that you shouldn't pay too much attention to your jokes. Instead, when you write scripts, you should pay a lot more attention to your storylines.
If your storylines don't work, no matter how much and no matter how hard you try to 'fix' your script by making your jokes - funny moments - funnier, you can't make your episode as a whole work. You need to fix your storylines first so that your jokes have the chance to work.
Nevertheless, there are situations where your storylines are almost good enough. They should and could be better, but your script includes elements that aren't completely hopeless. In these cases it might come down to how good your jokes are.
I think Modern Family's episode S6E22 is a good example of this. Even though there are pretty obvious story-logic problems especially with the episode's main storyline, in my opinion the episode was still surprisingly enjoyable to watch as a whole.
I mean, when it came to the flaws, there's pretty much no way on earth that Alex or Sanjay (where did that guy come up from?) would be crowned the valedictorian based on who runs 1 mile faster on a race track. The setup was convoluted to say the least.
Also, there were other minor problems too with the storyline that included Cameron & Mitchell taking part in a gay rally. I still haven't really figured out what happened in the opening scene in which a gay couple taunted Cam & Mitch.
Yet, for some reason this episode had a pretty uplifting mood and it didn't take itself too seriously. In my opinion the jokes - or should we call them funny moments - were likely the best that we had seen this season. They were genuinely hilarious and in character.
For example, I don't usually laugh out loud, but I got a good chuckle out of Manny's interview where he said that Gloria had better become a U.S. citizen - before Jay goes to play harp with Hendrix. This was a funny moment and I couldn't help but to laugh.
I also found it funny when Alex and Sanjay started the race and refused to finish it. I thought it was hilarious when Dr. Patel mentioned that they paid 1200$ to have a 1 hour skype conference with Usain Bolt in order to prep Sanjay.
These weren't malicious jokes and perhaps the best thing about the episode - despite its structural shortcomings - is that it managed to stay tongue-in-cheek and likable. Even the usually annoying characters, Cameron & Mitchell were bearable this time.
In any case, the main storyline wasn't that bad. In the end Alex and Sanjay decided that perhaps they should start dating in order to see where things would go. This was a nice moment that helped me to forget that the episode had problems elsewhere. It felt almost real.
All in all, Modern Family's S6E22 could have been better when it comes to its storylines being plausible. Fortunately it had other redeeming qualities that made me actually like the episode as a whole. It was uplifting - and as far as I'm concerned, I'm happy with that.