Meredith has affiliate partnerships. These do not influence editorial content, though Meredith may earn commissions for products purchased via affiliate links.

To read more Untold Stories, pick up the new issue of Entertainment Weekly on stands Friday, or buy it here — and subscribe for more exclusive interviews and photos, only in EW.

The day after the first test screening of My Best Friend’s Wedding, a studio executive turned to director P.J. Hogan and asked: “How are you going to save this movie?”

The movie always ended with Julianne (Julia Roberts) getting her much-deserved comeuppance and failing to derail the wedding of her best friend, Michael (Dermot Mulroney), and his future bride, Kimmy (Cameron Diaz). But in the original script, Julianne met a new guy (John Corbett) in the final scene. Test audiences hated it. “They wanted her dead,” says Hogan (who mostly recently wrote 2015’s Aussie romp The Dressmaker). “They just couldn’t understand her motives.”

Still, the studio wanted America’s sweetheart, Roberts, happy. “They were very nervous because we were making a Julia Roberts film and they couldn’t have her end up alone and unhappy,” explains Hogan. “So we had to come up with something that pleased the studio, but that was acceptable to the audience.”

Enter Rupert Everett as Julianne’s gay, charismatic confidant, George. “We expanded his character,” Hogan explains. “Every time Julianne talked to him, she’d explain why she was doing these terrible things; he’s her conscience throughout.” So Hogan went back and weaved in new sympathetic scenes with Everett. “Whenever she was being particularly devious I’d have her phone Rupert’s character and he would call her out on it.” Remember that scene near the end when Julianna confesses her love to Michael and winds up chasing him (as he chases Kimmy) in a bread delivery van? Hogan added a quick call with Everett to the scene, threw in the bluntly honest “Who’s chasing you?” line from George, and all of a sudden there was an element of empathy for Julianne. “I just asked myself, ‘What do I need to hear someone say to her at this point?'” says the director. “It was implicit in the scene, but she needed George to point it out to her.”

For more revelations from the past four decades of entertainment, visit ew.com/untoldstories.

Then, eight months after the film wrapped, Roberts was back on set (an expensive wig covering her recent pixie cut) to shoot the new ending. This time, George arrives at the wedding to dance with her at the reception after the new bride and groom leave.

“It would have been such a downer of an ending if George hadn’t shown up,” says Hogan. But as well as keep the tone light (and the studio happy), the final scene had a more important purpose. “That one scene somehow gave the audience permission to forgive Julianne,” Hogan says. “Those last five minutes really made the whole movie work.”

Episode Recaps Previous The 8 best rom-com engagement rings, appraised by The Bachelor jeweler Neil Lane By Shirley Li

See the exclusive portraits from EW's My Best Friend's Wedding reunion By Tim Stack

The 1997 Premiere of My Best Friend's Wedding Was a Time By Lauren Morgan Next