TNC: "Conundrum" (TNG S5, E14)
Matt and Andy watch the Enterprise crew have their minds erased. Not their whole minds, just the parts needed to stop the plot in its tracks. This also makes Riker seemingly irresistible to everyone and Data become a bartender. episode discussion begins around the 27 minute mark.