When Miranda Lambert decide to cut "Dammit Randy" to include on her Postcards From Texas album, she kept it as a surprise for her husband Brendan McLoughlin until after she'd finished recording the track.

McLoughlin co-wrote "Dammit Randy," and the song marks his very first songwriting credit on one of Lambert's albums — or any album, period.

During her recent appearance on Bunnie Xo's Dumb Blonde podcast, Lambert talks fans through the whole thing: What McLoughlin's reaction was after the big reveal, and why it meant so much to him to be included on his country star wife's new album.

"We cut it in the studio, he wasn't there all day, he came in in the afternoon," Lambert recounts. "I was like, 'I wanna play you something.' The whole band knew he'd written it, so we're just staring at him ... and we pushed play.

"He won't say it, but he got a little misty-eyed," she continues. "He's like, 'You cut my song?!' And it's one of my favorites on the record."

"Dammit Randy" actually isn't the first song the collaborated on together: Lambert says they wrote "probably four or five little tunes" during the 2020 pandemic lockdowns. Then, later, she and hit Nashville songwriter Jesse Frasure "made" McLoughlin come in and write with them after he cracked some poorly-received songwriting jokes.

"He was talking s--t to Jesse Frasure about, 'Songwriting's not that hard, it's easy.' So [Frasure] made him come in and do a little write," Lambert remembers with a laugh.

"We were there for, like, four-and-a-half hours. It's a lot. And he's like 'Oh, it is really hard.' We taught him a lesson," she goes on to say.

McLoughlin got an education that day, but he also impressed the room: He's got a natural talent for songwriting, and Lambert says they walked away with a "great song" that day.

Then, when Lambert and her co-producer Jon Randall were at her house working on Postcards From Texas, McLoughlin once again started chiming in with songwriting input.

"We started writing this song and Brendan kept piping in while he was watching football. I'm like, 'Are we doing this? In or out. You gotta turn the game off,'" Lambert remembers. "You're a songwriter, so get your pen out. We started writing it together and he wrote some of the greatest lines in the song."

The result was "Dammit Randy," a song that, Lambert points out, McLoughlin was especially well-suited to write. The song was inspired by her decision to leave her longtime label home, Sony, and how she knew it was time to walk away from a working relationship that wasn't suiting her anymore.

"Brendan is my husband so he's had to hear me b---h about it for so long that he kinda knew the story better than I did," she jokes, adding "I'm real proud of him."

Postcards From Texas is set to arrive next month.

Carena Liptak is an Associate Editor and staff writer at Taste of Country. She specializes in breaking country music news, interviews and lists. In particular, she’s got a soft spot for sad songs — check out her roundup of the 50 Saddest Country Songs of All Time!

The 25 Best Country Songs About Cowgirls

Gallery Credit: Carena Liptak

More From 100.7 WITL