42.5 hours before the wedding.
Before the wedding, Marshall had learned that room 13 of the Farhampton Inn is said to be haunted by the ghost of a dead man and somehow he and Lily ended up in that room for the weekend. Robin and Barney stumble across some minor issues regarding their tendency to do things without consulting with each other first.
Marshall recruits Ted (since he owes him a favor “no questions asked”) as his accomplice in deleting the text that got to Lily’s phone announcing his judgeship before she reads it. During a storm in the night, Ted climbs up the drain pipe to Lily’s room with the excuse that Marshall sent him to check up on her in the haunted room. He stays with her till she falls asleep, during which time he looks for her phone.
Unbeknownst to Ted, Marshall also requested Barney and Robin’s assistance in making sure Lily’s text never gets read. Once they’re all in Lily’s room (Barney via the air ducts like “the bad guy from Die Hard” and Robin hidden under the room service cart Lily didn’t order), Lily rushes out to complain to the manager. They rummage around for the phone only to realize Lily probably took it with her. As part of Barney and Robin’s solution to their “lone wolf” problem, they come up with an idea to work as a team and “prove they believe in marriage by helping Marshall hide something from his wife.”
While Barney and Robin are busy coming up with a cockamamie plan to destroy the text, Ted sneaks in and simply tells Lily to throw her phone on the ground and smash it with her foot because she also owes him a “no questions asked.” When Ted explains to Marshall how he got Lily to destroy the phone, he asks him why he didn’t just ask her the same thing and Marshall realizes he’d never want to keep anything from her. He asks Ted to put Lily on the phone and finally reveals the news about his judgeship to her. Lily threateningly responds that there might end up being a dead man in their room after all.