In the beginning, few had faith in the American version of “The Office” — including eventual star John Krasinski.

As the popular British workplace comedy was being adapted for TV, the producers started looking for unknown actors who could populate the fictional paper company, Dunder Mifflin.

Krasinki came in for an audition along with six or seven other hopefuls. But before he got his shot in front of the brass, a lunch break was called. As Krasinski sat in the waiting room, a man appeared and began munching on a salad. “Are you nervous?” he asked Krasinski.

“Not so much for the audition,” Krasinski replied. “But I’m really nervous for the people who are making this because so often these translations are just such garbage, and I really hope they don’t screw it up because so many people are waiting to kill this show.”

And the man sitting next to Krasinski said, “I’ll try my best. I’m Greg Daniels. This is my show.”

It was a cringeworthy moment the likes of which would later define the show.

Despite the faux pas, Krasinski got the part. And “The Office” would soon prove its doubters wrong, moving out of the shadow of its British inspiration and becoming among the most beloved comedies of modern times.

The show’s unlikely ascent is told in the new book, “The Office: The Untold Story of the Greatest Sitcom of the 2000s: An Oral History” by Andy Greene (Dutton).

“There are so few great sitcoms on now,” the author tells The Post. “It’s aged extremely well. It’s just classically funny.”

Its story began in the UK in the late 1990s when two friends — Ricky Gervais and Stephen Merchant — created a short film lampooning office culture.

Gervais starred as David Brent, a jerky middle manager who’s trying to impress a job interviewee.

The film became a viral sensation and was eventually turned into a full-blown series by the BBC.

The show was set at a paper company because paper is “something everyone uses, but you never really think about the manufacture or the sale of it,” Merchant says in the book.

The series was eventually brought to NBC for an adaptation with Daniels (“King of the Hill”) serving as showrunner. At first, execs eyed Gervais to reprise the boss role, but the comedian thought, “What’s the point of that? I’ve done mine.”

Finding the show’s lead — Michael Scott, “someone with the heart of a nine-year-old, but who plays between 34 and 44” — proved incredibly challenging.

The part was offered to both Paul Giamatti and Philip Seymour Hoffman, but both passed.

Bob Odenkirk was nearly hired, but producers worried he wasn’t “soft or likable” enough.

Instead, they tapped Steve Carell, an improv comic who was serving as a correspondent on “The Daily Show with Jon Stewart.”’

Although Carell was the show’s lead, its heart was meant to be the will-they-won’t-they romance between Krasinki’s Jim and the receptionist, Pam.

Jenna Fischer was a struggling actress who had actually worked as a receptionist for a time.

Fischer channeled her disinterest for that actual job in the improv audition. When the casting director asked her character, “Do you like being a receptionist?” Fischer replied blankly, “No.” Then offered no follow up, as a long awkward silence engulfed the room, before the producers cracked up.

Leslie David Baker, who played grumpy salesman Stanley, got his role due in part to bad LA traffic.

He had to drive across town to make the audition, fighting through slow drivers and clogged roads. When he arrived to read for the part, he was “sweaty and wrinkled and irritable and grouchy,” he says in the book.

The series was to be shot in a Culver City studio, but when it came to where it was set, Daniels envisioned a small city, close to a major one, that was on a “downswing.” Daniels looked at a map laid out on a table, dropped his finger on Scranton, Pennsylvania, and that was that.

Real businesses in Scranton sent truckloads of merch to the show, and some pieces were incorporated into the set, including a Froggy 101 radio station sticker on Dwight’s desk.

Daniels took the show’s mockumentary premise seriously, hiring a former reality show cameraman to lens the episodes. If a cast member’s cellphone were to accidentally ring during filming, Daniels would encourage him or her to answer.

The cast was also treated as though they worked at a real office, sometimes being forced to sit at their desk for an entire day. Some would surf the Internet, do their taxes or play solitaire to pass the time.

The show premiered March 24, 2005 with a strong 11.2 million viewers. Then the audience quickly halved when the next episode aired five days later. By season’s end, just 4.8 million were tuning in.

The show teetered on the verge of cancellation. But that summer, “The 40-Year-Old Virgin” hit theaters, turning Carell into an A-lister. “The Office” was given a second season.

Changes, however, had to be made. Michael Scott was seen as too abrasive, so the writers decided to humanize him.

“It’s the most crucial decision that they ever made,” Greene says.

The turning point came in the third episode of season two when the Dunder Mifflin staff hold their own office Olympics. At the finale, the staff presents Michael with a medal made of a yogurt lid.

“It was supposed to be just kind of like he’s taking it seriously … and everybody else is laughing behind his back,” director Paul Feig says in the book. “But Steve made this decision that as they’re playing the national anthem [he would] tear up. … He was so vulnerable and you see how desperate for … any kind of approval. I was like, ‘Oh, we can actually make Michael a nut, and overbearing … but we can find moments where he’s vulnerable and human.’”

Soon, the writers were churning out memorable episode after memorable episode via a competitive process that required each script to be brutally critiqued by the entire writing staff.

Some plotlines came from real life, like a fifth season gag in which the Dunder Mifflin staff measure their foot speed on a traffic radar gun they discover outside the office — something writer Aaron Shure actually did.

Michael Scott’s catchphrase “that’s what she said” started as a joke in the writers’ room.

“I think it was a whole year where we did that joke to ourselves. It was so hilariously funny that we’d be crying laughing,” writer Larry Wilmore says in the book.

As the years dragged on, however, the once-genial set began to get more tense.

“There were certain people that started to get egos,” first assistant director Rusty Mahmood says in the book. “They started demanding things. I’d hear, ‘I don’t want to come in that early.’ ”

The always-affable Steve Carell, according to those in the book, was willing to do more seasons of “The Office.” But NBC declined to renew his contract after season 7 (Greene guesses that Carell was too expensive and NBC no longer wanted to throw money at series that were critically well-reviewed but modestly rated).

His departure threw the show into crisis, and the staff argued fiercely about who should take over for Michael Scott.

Most favored having Rainn Wilson’s militant Dwight become the new boss, but after “The Hangover” series made Ed Helms a big movie star, his aw-shucks Andy was promoted.

The writers also brought in a new CEO character, and the choice came down to James Gandolfini, fresh off “The Sopranos,” and James Spader.

Spader joined the cast in season 8 (saying he took the job because he had been “hemorrhaging cash”) and quickly proved a poor fit.

“Spader is a good guy and he’s smart, but we needed brilliant comedians and James Spader isn’t funny,” executive producer Ben Silverman says.

“Michael was a load-bearing character,” Greene says. “He was like this magnet at the center of everything. They tried to fix it with James Spader and bringing in Catherine Tate, and you can see the flop sweat when you watch those episodes. It’s not working.”

The show was running on fumes until it finally ended with its ninth season in 2013.

There was some talk of launching a reboot built around Clark Duke and Jake Lacy, who joined the cast in the ninth season, but the idea was killed. A pilot showing Dwight’s life at his beet farm was also shot but was not picked up.

The series has enjoyed a new life online. It was the most-streamed show on Netflix in 2018, according to Nielsen.

“All I can say is that when something works as well as it does and is as smartly written as that show was and has the kind of cast that is just undeniable, as that show did, there is a kind of timelessness to it,” says J.J. Abrams, who directed one episode.

“I feel like [when] it’s 50 years, a hundred years from now, I don’t think the discomfort and awkwardness of working with odd people is ever gonna go away and that show captured that beautifully.”

“I think it’s very bingeable,” Greene adds. “Young people are discovering it. It’s not tied to one time period.”

“You can watch it forever and ever.”