Amidst the chaos of Joe's (Luke Wilson's) "rehabilitation", Rita (Maya Rudolph) spots plants growing from the White House's lawn, and, with the help of Frito (Dax Shepard) and a cameraman who was broadcasting the rehabilitation, they go to one of the fields, already bursting with small green plants, and show them on national -perhaps worldwide- TV. This allows President Camacho (Terry Crews) to give Joe the offered full presidential pardon for keeping his word, thus saving his life as well.
While everyone is having a big party, back at the White House, Joe tells Rita about using the time machine to return to year 2005, while Rita has considered to accept a job offer as CEO of Starbucks, and stay in the future. Then, President Camacho asks Joe to become his Vicepresident and, seeing as he could do something good for his "imbecile" fellow citizens, he accepts. Then, we discover that the alleged Time Machine was actually an amusement park attraction that showed a weird, dumbed-down version of History of the 20th. Century.
Time passes, and Joe goes from Vicepresident to President of the United States. Rita becomes his First Lady; they marry and have 3 children -appointed the three smartest children alive-; meanwhile, Frito, who became a member of Joe's cabinet, married 8 women, and had a total of 32 children, the dumbest of the world. In the end, Joe never got to figure out that Rita couldn't even paint a caricature (she is shown trying to do a lame portrait of Joe), and that she was actually a hooker.
Thanks Dr Mat!