That was “The Enemy Within”. One of my favorites.
Incidentally, “Mirror, Mirror” is consistently on the list of Star Trek fans’ Favority Episodes. In fact, IIRC, it usually tops such lists.
Regards,
“Star Trek Enterprise” had a “Miror, Miror” episode, I wonder why TNG didn’t.