Jennifer Garner, Nikolaj-Coster Waldau

Jennifer Garneris spilling behind-the-scenes secrets from filmingThe Last Thing He Told Me.

The prank took place as the actor prepared to film his character’s return years afterhis mysterious disappearancecaused his wife Hannah (Garner) to forge a relationship with her 16-year-old stepdaughter Bailey (Angourie Rice) to get answers.

“I was talking toJosh [Singer], and it seemed like a background player came and sat next to me,” shared Garner. “And Josh kind of started smiling. And this person was just getting more and more comfortable next to me, and I thought, ‘I don’t know you.'”

Alberto Rodriguez/GA/The Hollywood Reporter

Jennifer Garner, Nikolaj-Coster Waldau

Garner told the outlet that Coster-Waldau, 52, had been off-set traveling, so she was unaware he was back on set in a new costume that included a beard and hat.

“I instantly was just… I was so shocked. He was in a beard,” she explained. “They were testing his look for the last scene. And he just completely, completely caught me off guard. And, you know, I cried, and I yelled at them. And then we went on.”

While Coster-Waldau joked with the outlet that pulling the prank was “a lot of fun,” he shared that he also enjoyed the moment because it showed Garner’s dedication to her role.

“It was an emotional reaction she had,” he said. “And it was beautiful because she was very much in character. She was so invested in this relationship.”

Never miss a story — sign up forPEOPLE’s free daily newsletterto stay up-to-date on the best of what PEOPLE has to offer, from juicy celebrity news to compelling human interest stories.

source: people.com