The episode opens as SpongeBob is taking his driving test yet again. He ends up leaving the driving course and wrecking the boating school and the city, before driving off an unfinished bridge and falling into an abyss. The police follow the boat and end up driving off the bridge and into the abyss themselves. SpongeBob, Mrs. Puff, and the police all land on top of a truck full of fruit punch being delivered to Shady Shoals Rest Home, causing it to fall over and spill, flooding the rest home. Although SpongeBob is responsible, the incident occurred under Mrs. Puff's supervision, and she is sent to prison for gross negligence. In prison, she realizes that she will not see SpongeBob again for a very long time, and starts to enjoy it.
Meanwhile, SpongeBob is depressed that Mrs. Puff is in jail, and Patrick tells him that it is SpongeBob's fault. The duo sets out to free her from jail. First, they try to rob the bank in order to get arrested themselves, but SpongeBob gets wrapped up in the bureaucratic niceties of banking and forgets they are trying to commit a crime. Next, they disguise themselves as rocks that the prisoners smash as labor. They try to communicate with Mrs. Puff, who calls the guards, but they dismiss her conversation with two rocks as a hallucination and move her to kitchen duty. SpongeBob and Patrick are then smashed by another inmate, costing them their deposit on the costumes. Then they hide in a vat of chili in the cafeteria and offer to help Mrs. Puff escape through it, but she explains to them that she likes it in prison, which SpongeBob refuses to believe. He worries that Mrs. Puff is completely institutionalized in prison and he needs to get her out. In an attempt to coax her, SpongeBob tells Mrs. Puff if she can escape, he will stay after school and decorate the entire classroom, but Mrs. Puff refuses. She calls for the prison guards again and is reassigned again after the prison guards believe that Mrs. Puff is going crazy.
SpongeBob and Patrick appear to her yet again on a coat hanger assembly line, and when she calls for a guard, he somehow perceives SpongeBob and Patrick as raw materials used to make the coat hangers and dismisses her to her cell once again. SpongeBob and Patrick then appear in Mrs. Puff's cell toilet, asking her to hop in, and when Mrs. Puff calls for a guard again, he simply flushes them down the toilet and leaves. They then appear in her bed, and Mrs. Puff calls for the guards yet again, but this time the two guards that appear are SpongeBob and Patrick in disguise. After they leave, the real guards show up after hearing her screaming and crying, but Mrs. Puff thinks its still SpongeBob and Patrick in disguise and rips off their faces. This is the last straw for the guards, who strap Mrs. Puff into a straitjacket and throw her in a padded cell for solitary confinement, convinced she's completely lost her sanity. Despite this, she is glad to finally be alone and away from SpongeBob, but suddenly his face appears all over the walls and floor of the padded cell and begins laughing at her.
Mrs. Puff screams in horror at the incessant laughing as the scene transitions back to SpongeBob driving off the cliff and crashing into the fruit punch truck, once again flooding the rest home. Mrs. Puff stumbles out of the wreckage and is confronted by the police again, but to her surprise this time, they arrest SpongeBob instead of her. From this, she concludes that her prison sentence was merely a hallucination and is happy that she's not going to jail, but after a police officer informs her that she "already did [her] time", Mrs. Puff suddenly sees herself wearing a prison uniform with a chain on her ankle.
She once again screams in horror as the scene transitions back to her sitting in the boat going off the cliff again, seemingly having suffered another hallucination, but this time she sees Donna, a prisoner with a masculine voice from her first hallucination, driving the boat instead of SpongeBob. Screaming yet again, the scene transitions back to Mrs. Puff sitting in the boat driving off the cliff, this time with SpongeBob behind the wheel and no police cars behind them. Exasperated, Mrs. Puff says "Oh, forget it." immediately closing the episode.
It is revealed that Mrs. Puff's first student in her boating school was SpongeBob. As of her flashback, this explains the origin of her boating disaster.
In this episode, the boatmobile SpongeBob uses to take the test is painted blue as opposed to red.
This episode is an example of recursion, a never-ending cycle.
There was going to be a scene where Mrs. Puff's dad would appear, as his name is still listed in the credits of this episode, with Tom Kenny being credited for voicing him. His dialogue had already been recorded when he was cut from the episode. C.H. Greenblatt, who storyboarded and co-wrote "Doing Time," said that he did not remember anything about the episode when asked about Mrs. Puff's father in 2017.[3]
Originally, this episode would have ended at the scene where SpongeBob gets arrested instead of Mrs. Puff, who then finds out she already went to prison. This was instead used as part of the daydream sequence.[citation needed]
This marks the first time to feature Shady Shoals Rest Home without Mermaid Man and Barnacle Boy.
This is the second episode in which the majority of the runtime is a product of a character's imagination. The first is "Procrastination."
This is the third episode where Mrs. Puff goes to jail (if only in a dream sequence). The first was "Hall Monitor," and the second was "No Free Rides."
The font of the title card is later used in "Squidiot Box."
Instead, she says the same wrong words from Template:Data:Links with her voice from the episode "Mermaid Man and Barnacle Boy IV." This is likely caused by the dubbing staff confusing the inmate and Sandy's southern accents.
During the bubble transition there is a blue screen that was made sometime in 2001 by Rough Draft Korea. This is possibly the result of a compositing error.
While Billy Gus is looking at the window, it is supposed to be night but instead it takes place during the day but dark.
The coals and the coat hangers do not move uniformly on the conveyor belt. When SpongeBob and Patrick appear on the conveyor belt, the coat hangers move faster than them and towards off-screen.
File:Chiliyelloweye.webpSpongeBob with yellow eyesWhen SpongeBob tells Mrs. Puff that Patrick came along because he likes chili, his eyes are yellow for a split second.
On a traffic scene in "life on the outside" cutaway gag, the boat behind Incidental 107's boat is missing its driver.
When Mrs. Puff gets thrown into "solitary confinement," there is a rubber duck in the corner in the first scene. It disappears in the very next scene Mrs. Puff hallucinates the wall as SpongeBob.
In the close up shot of the police officers beating up a parking meter, the emblem on Incidental 118B's hat is colored black instead of gold.