Harry Potter and the Chamber of Secrets
Moaning Myrtle initially seems like a joke character along the lines of Nearly Headless Nick, but she does have a couple of important functions in the plot of Book 2. She's a miserable, mopey ghost who haunts a girl's toilet in the castle. She loves to feel sorry for herself and she takes pleasure in other people's misfortunes. She's positively gleeful when Hermione turns herself halfway into a cat. In fact, Harry "had never seen her looking so happy" (12.197). So Moaning Myrtle is not a nice girl who we all want to be friends with. Even so, Myrtle's self-pity plays a useful role in the plot. When someone throws Riddle's diary into Myrtle's toilet, all of her crying and carrying on alerts Harry to the book.
Of course, Moaning Myrtle becomes even more important to the plot when Harry and Ron figure out that she must be the Muggle-born girl killed fifty years ago, the last time the Chamber of Secrets was opened. She tells them that she died looking up into a pair of yellow eyes, which appeared near the sinks in her bathroom. That's how Harry and Ron find the entrance to the Chamber of Secrets where the basilisk is waiting.