You are referring to the plot arc from EP022, "Abra and the Psychic Showdown" through EP024, "Haunter versus Kadabra". In order to defeat Sabrina, Ash has to use a Ghost-type Pokémon, as Ghost-type moves are (technically, at the time, were not) super-effective against Sabrina's Psychic-type Pokémon. Note that Ghost-types are only immune to Normal-type attacks, and they're definitely not immune to Psychic attacks. (In fact, the only Ghost Pokémon in existence when the episode aired were all weak to Psychic attacks, as they were part Poison-type!)
Anyway, back to the plot. Ash befriends (but does not capture!) a Haunter in EP023, and when he challenges Sabrina with it, the Haunter proceeds to pull pranks and make Sabrina laugh, breaking her emotionless façade and allowing Misty & Brock (whom Sabrina turned into dolls) to return to human form. As thanks (and because Ash is some sort of dumb-luck Mary Sue), Ash is awarded Sabrina's Marsh Badge, and the Haunter stays behind with Sabrina, whom it has befriended.
So the Haunter belongs to Sabrina now, not Ash, and it wouldn't have been invincible anyway.