It's clear that at this point Lester envies Kirk's position as a starship captain, perhaps because it's what she sees as having kept him from her. The Enterprise is in effect the "other woman" he jilted her in favor of. And it's equally clear that at this point she "would not be allowed to serve as captain," for good reason, due to her obvious mental instability and her impostory. It might even be clear that she believes she is disqualified because of her gender, but that doesn't necessarily make it true.
Don't get me wrong, I'm not really in denial of the likely intent here, but in retrospect there's just enough room to circumvent or ignore it. And unless you've got a workable theory for why Starfleet would allow, then categorically disallow, then allow again women to command starships, I think the bulk of the canonical evidence suggests that we should do just that in this case.
What makes the situation different with respect to fleet structure and political authority, you might ask? Because there the differences we see in evidence from the 22nd century to the 23rd to the 24th can actually be seen to make sense as a logical and broadly consistent progression over time, IMO. But of course, YMMV.
The most typical explanation is the out of universe one; the later shows retroactively cleaned up that embarrassing piece of sexism, but not being able to edit out the dialog in this episode still leaves an odd taste.
Actually your interpretation fits almost perfectly to explain this, but there is still too much conflicting dialog from the characters to ignore the problem.
(Janice as Kirk): Now you know the indignity of being a woman. For you this agony will soon pass, as it has for me. Quiet. Quiet! Believe me, it's better to be dead than to live alone in the body of a woman.
JANICE: Oh, I'm never going to be the captain. Never. Kill him.
This episode was clearly pointing to something being wrong.
It's not too much of stretch, since lately some fans have been saying that trek humans aren't really all that socially evolved as they claimed: that they're the same as "us" only more prosperous.
By the way, this is one of my favorite episodes. It's not supposed to be funny, I know, but it's unintentionally hilarious
