Mr. Krabs holds a yard sale with items found in the trash, and SpongeBob buys a soda drinking hat. Later, Krabs is confronted by a group of rich collectors, who inform him that the soda drinking hat he is in possession of is extremely valuable, and offer to pay him up to one million dollars for it. Mr. Krabs goes to SpongeBob and desperately tries to get him to give the hat back, but to no avail. Mr. Krabs then concludes that he will have to "scare" the hat off of SpongeBob.
That night, Mr. Krabs draws an obviously fake ghost on a piece of paper and puts it through SpongeBob's window using a fishing rod. SpongeBob thinks it's a real ghost, and Mr. Krabs tells him that the hat is cursed, and must be returned to its deceased original owner. When SpongeBob asks the name of the owner, Mr. Krabs hastily makes up the name. However, Mr. Krabs' plan backfires when there turnsout to be an actual dead person with that name, and that SpongeBob buried the hat in his grave.
Mr. Krabs goes to the cemetery, where he gets scared and hides behind a headstone, when along comes Squidward bringing flowers to a grave labeled "Squidward's Hopes and Dreams" and remarks "What a baby". Mr. Krabs then proceeds to remember things SpongeBob has said to him, and uses that information to find and then defile Smitty's grave and take the hat. However, Smitty and the others buried in the cemetery suddenly come to life, and attempt to get the hat back. Mr. Krabs grabs the head of an undead swordfish, and uses that as his sword. He fights the undead skeleton warriors all night, eventually defeating them all and escaping with the hat. He then goes to the collectors and tells them that he got the hat back, but the collectors laugh at him telling him that they found a warehouse full of soda drinking hats and that it's now worthless. The collectors see SpongeBob wearing a clapping hat and they chase him, offering to pay one billion dollars for his hat. Mr. Krabs starts crying, and Squidward, who was seen bringing flowers to the grave of "Squidward's Hopes And Dreams" in the graveyard, says "What a baby".
When Mr.Krabs gets the "million dollar" hat, he goes back to his back yard where the previous buyers of the hat are all gathered, later to find none of them are interested in buying the hat at all. This is unrealistic that they would all still be waiting for him to return having known that the hat is now worthless.
The name of the episode is a reference to the saying "One man's trash is another man's treasure", coincidentally, The French narrator says that exact same phrase at the beginning of the episode.