Mila Kunis did not come back to play Lori because she was pregnant. In an early draft of the script, someone mentioned that Lori died between the two movies. That idea was considered too depressing, so it was changed to John and Lori getting divorced.
One of the depressing suggestions at the improv show is "9/11". Mark Wahlberg and Seth McFarlane were scheduled to fly on American Airlines Flight 11 that morning, but Wahlberg's plans changed, and MacFarlane got to the gate too late to board.
For the scene where Ted hides from Donny amongst other Ted plushes, the production purchased commercially available Ted plushes and then added a new mouth for each one with CGI to match the movie Ted's appearance. This saved money as opposed to creating more original ones for filming. This is mentioned in the commentary.
The plot was inspired by Seth MacFarlane reading John Jakes' Civil War novels on the side while filming A Million Ways to Die in the West (2014). It replaced his original plot of Ted and John driving a large shipment of marijuana cross-country, which was scrapped after We're the Millers (2013) came out.
When the trio are stranded at the pot farm, Amanda Seyfried really sings Samantha's song. "Mean Ol' Moon" was written especially for this movie, and the lyrics were penned by Seth MacFarlane. In an interview with "USA Today", Seyfried said, "It took like a week, but we did it, and it actually works."
Kate McKinnon, Bobby Moynihan, Taran Killam: As themselves, in a Saturday Night Live (1975) skit parodying Ted's trial.
Seth MacFarlane: [reusing Family Guy gags] In the Comic-Con scene, two cosplayers dressed as Peter Griffin and a giant chicken fight. John spills semen on himself, like Peter did in Sibling Rivalry (2006). Ted plays a fake piano while listening to "Mess Around." A Stormtrooper did the same in It's a Trap! (2011), in turn a reference to Planes, Trains & Automobiles (1987).