Just six weeks ago, the coworking giant WeWork was the US's most valuable tech startup.

Then it filed its S-1 registration for an initial public offering, disclosing a bevy of conflicts of interest and mismanagement by its magnetic and eccentric cofounder, Adam Neumann.

Investors, reporters, and analysts, chastened after seeing Theranos revealed as a massive fraud and watching Uber fail to live up to the hype, didn't let another visionary founder pull the wool over their eyes.

Neumann's IPO dreams crashed and burned, and now he's been ousted as CEO and observers are wondering whether WeWork can avoid bankruptcy.

Based on reporting from Business Insider and other news outlets, this is the story of the six weeks that almost ended WeWork.

Also read: Sex, tequila, and a tiger: Employees inside Adam Neumann's WeWork talk about the nonstop party to attain a $100 billion dream and the messy reality that tanked it

At 7:12 on a mild late-summer morning in New York City, WeWork's registration papers hit the Securities and Exchange Commission's website. The filing, called an S-1, was expected. It was a crucial step in what up to that point had been an exquisitely choreographed march toward an initial public offering for the tech world's most highly valued startup.

With its stratospheric $47 billion valuation and preposterously ambitious cofounder and CEO, Adam Neumann — his goal wasn't merely to make money or rent office space, he claimed, but to "change the world" — WeWork had become a glaring symbol of Silicon Valley's boundless audacity and self-professed exemption from the laws of economics.

In the early-morning light, thousands of investors and journalists would get their first real peek at the company's financial condition and be able to judge for themselves whether WeWork was really, as its founder claimed, on a path toward galactic dominance and unimaginable profit.

Almost immediately, all hell broke loose. A steady stream of rapid-fire headlines detailed Neumann's self-dealing, mismanagement, and bizarre behavior. Within 33 days the offering was scuttled, WeWork's valuation plummeted 70% or more, and Neumann, who believed he would become the world's first trillionaire, was ousted as CEO. What was supposed to be Neumann's coronation as a visionary became one of the most catastrophically bungled attempted debuts in business history.

Read more: WeWork's board just ousted Adam Neumann as CEO — here's who the key players are

It wasn't supposed to be this way. WeWork was a unicorn, a near-invincible powerhouse flush with venture capital. The most brilliant minds in Silicon Valley and the most powerful global investors had shoveled billions of dollars into its coffers — how could it be anything but a sure bet? Validation from public-market investors was a mere formality.

But two things had changed in the nine years since Neumann began constructing the myth of WeWork with the help of starry-eyed tech journalists and hungry investors: Theranos and Uber. In the fall of Theranos, the blood-testing company that imploded under accusations of fraud, the investing public saw how a multibillion-dollar valuation could be spun up from Silicon Valley bromides and the image of an idiosyncratic, enigmatic founder who inspired cult-like devotion. In Uber, whose stock has trended downward since it went public, they saw how machismo, hubris, and accounting tricks could obscure fundamental business challenges.

Unfortunately for Neumann, it was precisely the wrong time to be the visionary leader of a company with imperial dreams and obscure finances. Patience had run out.

This account of the six-week period since that August 14 filing is based on Business Insider's own reporting, as well as that of The Wall Street Journal, the Financial Times, The New York Times, Bloomberg, New York magazine, Vanity Fair, and other publications.

The WeWork cofounder Adam Neumann. Jackal Pan / Getty Tech-bro mysticism, grueling hours, and Don Julio tequila

Neumann, a 40-year-old Israeli Navy veteran, is known for his signature look of long unkempt hair above a T-shirt and jeans and bold pronouncements bordering on the bizarre ("On the one hand, community," he once told New York magazine, describing his simultaneous desire for social cohesion and cutthroat competition. "On the other hand, you eat what you kill.")

He spent time on a kibbutz and has described his early life as troubled. His parents divorced when he was 7, and he moved 13 times as a kid and into his teens, according to a Reuters profile. He moved to New York in 2001, when he was 22, to live with his sister, a model, in Tribeca. He attended business school, "hit on every girl in the city," and built failed businesses around collapsible women's high-heeled shoes and baby clothes with knee pads ("Krawlers").

WeWork, which now has 12,500 employees, had always been a little different. Neumann founded it in 2010 with Miguel McKelvey, who was raised on an Oregon commune. The bulk of the firm's business is in renting out space in buildings and then sprucing it up and parceling out smaller chunks to freelancers, startups, and other businesses for shorter time frames. While WeWork typically takes out 15-year leases, some of its customers can move out in a month.

It often seemed like a real-estate company posing as a higher plane of consciousness. Together with his wife, Rebekah, a devout follower of Kabbalah who is a cousin of Gwyneth Paltrow, Neumann cultivated a sort of tech-bro mysticism, combining grueling hours and always-on expectations with a free flow of alcohol and hippie wisdom. Rebekah started a private elementary school and played up WeWork's community of tenant workers.

Adam walked around the office barefoot. He once decreed that no one should eat meat in the office or purchase it on company expense accounts. He also partied hard: Neumann was known for drinking Don Julio 1942, the $149-a-bottle tequila. And he smoked marijuana in the office, at his various homes, and elsewhere, people who'd seen him smoke it told Business Insider.

The trappings of success

The trappings of success soon followed. In recent years, Neumann purchased at least five homes, including a $10.5 million Greenwich Village townhouse, another in the Hamptons, and yet another, a 60-acre estate, north of New York City. In 2017, he spent $35 million to buy four apartments in the same building in the tony Manhattan neighborhood of Gramercy Park. He purchased a $60 million Gulfstream jet for WeWork, which flew around the globe to London, Panama, the Dominican Republic, Tokyo, Hong Kong, and Hawaii, among other locations. Neumann's successors are moving to sell it.

The company's prospectus reflected the Neumanns' eccentricities. It opened with a dramatic pronouncement: "We are a community company committed to maximum global impact. Our mission is to elevate the world's consciousness." The inside cover carried a dedication to "the energy of we — greater than any of us but inside all of us." It included a commitment from the Neumanns to donate $1 billion in cash and stock — wealth they hadn't earned yet — to charity as well as a pledge to save 20 million acres of rain forest.

Rebekah Neumann wielded significant influence over the language in the filing — internally referred to by the codename "Project Wingspan" — according to two sources with knowledge of the process. It listed the company's underwriters in a circle instead of the customary pecking order. Months earlier, they'd changed the company's name from WeWork to just We, to better communicate the enormity of their ambitions. An earlier version of the prospectus listed a series of competitive advantages under the heading "Our Superpowers."

Read more: Sex, tequila, and a tiger: Employees inside Adam Neumann's WeWork talk about the nonstop party to attain a $100 billion dream and the messy reality that tanked it

If the WeWork IPO was supposed to be a validation of Neumann's grand spiritual plan, for his sponsor and largest backer, Masayoshi Son, the CEO of the Japanese conglomerate SoftBank, it would vindicate his controversial strategy of plowing billions of dollars into promising startups and pushing them to spend gobs of money to dominate their market. Son was out fundraising, even as some of his biggest investments, like the ride-hailing firm Uber, had failed to live up to expectations. This would be the stamp of approval he sorely needed.

Son and Neumann had met for less than 30 minutes back in 2016 before Son decided to invest in WeWork. He would eventually pledge $10.7 billion, either from SoftBank's coffers or those of a separate vehicle established by Son called the Vision Fund, which raised $100 billion from backers including Saudi Arabia. After those investors balked at putting in any more money (Vanity Fair reported that Neumann arrived late and appeared hungover for an investor meeting), it was SoftBank's $2 billion investment round in January that secured WeWork's most recent $47 billion valuation.

Bankers and investors had also bought into the hype. JPMorgan Chase and Goldman Sachs were running the IPO — after dangling potential market caps as high as $63 billion and $96 billion.

Representatives for Neumann, WeWork, JPMorgan Chase, and Goldman Sachs declined to comment on the record for this story. A representative for SoftBank did not immediately respond.

SoftBank CEO Masayoshi Son. Kim Kyung-Hoon/Reuters 'We have a history of losses'

Trouble began almost as soon as the 359-page S-1 filing hit the internet. Investors, analysts, and journalists began digging in, and they didn't like what they found: a laundry list of potential conflicts between Neumann and the company, a byzantine corporate structure, and losses that were growing even as revenue doubled. The company didn't explain how it would become profitable. The section disclosing risks to investors ran to almost 30 pages.

The potential conflicts were astounding: Neumann owned an interest in four buildings that WeWork leased. He'd gotten personal loans from the company at below-market rates to fund his lavish lifestyle. One, for $362 million, was connected to an early exercise of stock options (and has since been repaid). He had a $500 million line of credit secured by his shares. Perhaps most alarmingly, he had purchased the trademark to the "We" name through a holding company, and WeWork paid him $5.9 million to license it. "Related party" citations in the prospectus — disclosures that the company was doing business that could enrich an employee, director, or officer — numbered more than 100.

Read more: WeWork details CEO Adam Neumann's web of loans, real-estate deals, and family involvement with the company

He'd also used company money to fund what looked like pet projects, including several entities linked to Neumann's love of surfing. It led a $32 million investment into the surfer Laird Hamilton's startup, Laird Superfood, and sank $14 million into Wavegarden, a company that makes surfing-wave pools.

Neumann had near total control. WeWork would have three classes of stock, including two that awarded Neumann 20 votes for each share. Upon death, his wife would have the power to name a new CEO, independently of the board.

But perhaps what made WeWork different is the apparent problems with the company's business model. It was on the hook for $47 billion in future lease payments to building owners while having committed revenue of only $4 billion. Last year's loss jumped to $1.9 billion on revenue of $1.8 billion — for every dollar it made, it was spending two. For the first half of this year, losses climbed to $904 million even as revenue doubled to $1.54 billion. The company also used a made-up metric that it called "contribution margin" — renamed from the "community-adjusted Ebitda" that was much maligned earlier in the year — that made it harder to understand how the underlying business was performing.

"We have a history of losses and, especially if we continue to grow at an accelerated rate, we may be unable to achieve profitability at a company level," the firm said in its filing, "for the foreseeable future."

Read more: WeWork might be painting itself as a tech company, but it's facing a bunch of old-school real-estate worries

It was a lot to take in. By the end of that day, both the Financial Times and The Wall Street Journal were suggesting that the company might have to reduce its valuation to attract interest. Analysts quickly joined the fray, with Fitch Ratings moving that day to downgrade the company lower into junk territory over its profligate spending, among other factors.

If that weren't enough, Neumann got another bad omen: Faraday Grid, a UK-based startup looking to build new power transformers into which Neumann had invested 25 million pounds earlier this year, filed for bankruptcy.

It was less than 24 hours since the company's filing had been made public.

'A masterpiece of obfuscation'

Triton Research's Rett Wallace would later call the prospectus a "masterpiece of obfuscation."

The New York University marketing professor Scott Galloway wrote a takedown of the company titled "WeWTF." John Coffee, a Columbia University professor who directs the university's corporate-governance center, told the Financial Times that to navigate past investor concerns about the company's structure, market volatility, and a tougher climate for IPOs, Neumann would have to "go through an ordeal of fire."

Read more: WeWork opened 400 locations in 3 years. In some cases, it used deep discounts to convince existing customers to relocate to help fill them.

While some of the company's advisers were surprised at the speed and depth of the negative reaction, according to a person familiar with their thoughts, WeWork execs remained bullish on the company's prospects throughout that week and into the summer weekend. WeWork's bonds rallied by more than 3% on hopes that the IPO would pay off.

But the brutal headlines kept coming: On Monday, August 19, the Financial Times' editorial board blasted WeWork and Neumann for the lock he kept on the company. The title was "Beware the dead hand of the controlling founder." In The New York Times, Kara Swisher asked, "WeWork: Is there any there there?" Another Financial Times opinion article led with "WeWork's magical thinking disguises a flawed model."

"Hype is one of the tech sector's most magical qualities," Elaine Moore wrote in the Financial Times. "Like Uber and Lyft, no one can say for sure whether its business actually works."

The company's advisers continued to survey investors, trying to drum up support for an IPO they hoped would raise at least $3 billion. They weren't getting a positive reception. Shortly after 4 p.m. on Monday, August 26, Neumann hopped on the WeWork Gulfstream for a 13-hour red-eye flight over the arctic to Tokyo to speak with SoftBank investors about the state of the IPO.

The discussion centered on two possibilities: whether SoftBank would be a big buyer of shares in the IPO, which would be hotly debated for weeks after, or whether the Japanese conglomerate might inject a new slug of operating cash so WeWork could delay the offering.

The talks ignited a long-simmering difference of opinion within SoftBank, where some execs had argued against investing any more money into the company. Son, however, remained committed to Neumann and his vision. And he held considerable sway. Neumann needed the money — $9 billion in IPO proceeds and bank debt — to fuel his continuing global ambitions.

We cofounder and CEO Adam Neumann Getty A humiliating comedown

But by early September, something had to give. WeWork's bankers weren't having any luck drumming up enough support for the IPO, hearing from investors concerned about signs of Neumann's self-dealing and skepticism about the business model.

On Wednesday, September 4, the retrenchment began. Neumann agreed to return the $5.9 million payment he had gotten from WeWork for the rights to use the trademarked term "We." The company also announced that Frances Frei, a Harvard professor and adviser to the company since March, would join the board, responding to criticism about its lack of a single woman. Newspapers reported the company was preparing to kick off its IPO road show as soon as the following week.

But the next day, another drumbeat of negative news about valuation flooded the media. While some had suggested early on that the company's lofty valuation might need to be trimmed, things had gone quiet as advisers canvassed investors. No more.

Numerous outlets reported the company was considering selling shares at 50% of its most recent private valuation, or $20 billion to $30 billion. Yet some company insiders still hoped to be able to get something in the range of $25 billion to $30 billion.

It was a humiliating comedown from the hype that had followed the company and Neumann for years. Any lower and WeWork would be forced to wear the ignominious crown of Silicon Valley's biggest-ever public down round.

The reasons for the knockdown were well publicized, though members of WeWork's camp tried mightily to paint it as a prudent step: The Financial Times said the firm's underwriters were worried about listing the company at too high a valuation and risking a repeat of what happened with Uber, which has fallen about 33% since its debut.

Desperately trying to keep the IPO on track

By Sunday, September 8, the company was considering a valuation below the $20 billion that had been floated just days before. WeWork had been planning to begin its road show the following day, and yet the company and its advisers were still holding meetings to see what they could do to drum up more demand.

By Monday, if not before, SoftBank decided it had seen enough. Executives at the conglomerate and its $100 billion Vision Fund were pushing Neumann to abandon the IPO.

For SoftBank, it was a stunning reversal. After plowing more than $10 billion into the company, and taking a 29% stake, the firm and its leader, Son, needed a big win. Yet it couldn't stomach a public-market valuation just one-third of the private value it had given WeWork as recently as January.

By Thursday, September 12, WeWork was considering reducing Neumann's voting power from 20 votes a share to 10 votes in an effort to win over investors. Neumann was "desperately" trying to keep the IPO on track. WeWork canceled a planned town hall.

Friday was a big day. WeWork was hoping to begin its road show the following week, and it made another attempt to woo investors with changes to corporate governance. The company publicly announced changes that day, taking the steps the Financial Times previewed, and made numerous other changes at the same time. The company cited "market feedback" for the adjustments and said no member of Neumann's family would sit on the board. The plan for Rebekah Neumann to choose a successor in the event of her husband's death was also scrapped, and the filing said the board had the ability to remove the CEO.

Reuters reported the company was looking at a valuation of $10 billion to $12 billion. That would value the company at less than the $12.8 billion in total equity it raised during its nine years of operations.

Neumann remained committed to going forward with the IPO, hoping to complete the listing before Rosh Hashanah so he could observe the Jewish High Holidays. In talks earlier that week with SoftBank, the CEO said he didn't expect any changes over the coming 12 months and what he really needed was more cash to fund his plans for expansion. Neumann was also counting on a $6 billion loan that his bankers would give to WeWork — but only if he successfully raised at least $3 billion in the IPO. Later that Friday, the firm announced plans to list on the Nasdaq.

The interplay between Neumann and his advisers was fraught throughout the process, according to people familiar with the matter. The CEO resisted some of his advisers' suggested changes to the IPO filing, particularly around the control and voting structures, one of the people said. And JPMorgan insisted on disclosing some of the related-party transactions that would later prompt the investor backlash. Neumann wasn't even listening to his largest sponsor, SoftBank, who wanted to shelve the IPO.

He plowed ahead, and SoftBank had little choice but to go along with the plans of the man they had invested so heavily in. By Friday afternoon, news reports suggested that SoftBank was prepared to act as the anchor investor in the IPO, purchasing at least $750 million in shares in the offering.

Heading into the weekend, WeWork, SoftBank, and its advisers were hoping that the corporate-governance changes, valuation markdowns, and pledge of SoftBank support would be enough to launch the long-awaited road show.

It would be some of the longest 48 hours of Adam Neumann's life.

FILE PHOTO: The WeWork logo is displayed on the entrance of a co-working space in New York Reuters A bombshell hits

By Monday, instead of starting the road show, WeWork announced plans to postpone the listing until after the Jewish holidays. Even with SoftBank's anchor investment, the company and its advisers had decided it would still raise less than the $3 billion it needed to unlock the $6 billion loan that it needed to keep operating.

The company issued a terse statement that said it looked forward to completing the IPO by the end of the year. Any further delay beyond that, and the clock would run out on the terms of the loan, which would have to be renegotiated.

The day after shelving the IPO, Neumann acknowledged in an internal webcast to being humbled. It was a new low for the founder. He now realized, he told his employees, that the skills he'd developed to run a private company would need to be adapted to run a public corporation. By this point, members of the board had begun thinking about how they could force him to resign, according to multiple reports.

Shortly after noon, the bombshell hit.

The Wall Street Journal's Eliot Brown dropped a 2,864-word, deeply reported article detailing Neumann's frequent marijuana use and propensity for shots of tequila. The newspaper told of a flight to Israel in which the owner of the jet recalled it after finding marijuana in the cabin. And of a layoffs discussion followed with tequila shots and a performance by a member of Run-DMC.

The article was a turning point in how his investors and employees saw him, according to a person with knowledge of those views. In the coverage that followed across news organizations, the CEO's marijuana use would be frequently mentioned.

Sliding toward possible bankruptcy

That was it. By Sunday, SoftBank was pushing to unseat Neumann. Faced with allegations of drug use, erratic behavior, and earlier defiance in pursuing the IPO even after his largest investor cautioned patience, SoftBank had lost faith. Some large investors had said they wouldn't invest unless the company brought in a more experienced executive. Several investors even thought of threatening the CEO with legal steps related to his self-dealing. A board meeting was scheduled for later in the week.

Read more: JPMorgan's Jamie Dimon met with WeWork's Adam Neumann this weekend to hash out how to get its botched IPO back on track

That Sunday, Neumann sat down with JPMorgan CEO Jamie Dimon, whom he liked to call his personal banker. Like the consigliere J. Pierpont Morgan a century before, Dimon found himself in the midst of the biggest corporate story of the moment. The two men discussed what could be done to get the delayed IPO back on track, Business Insider first reported. Dimon also brokered talks with Neumann's advisers over the course of two days at the bank's midtown headquarters, a person familiar with them said.

Dimon was more than a neutral ear. In addition to serving as the bank's top IPO adviser, JPMorgan has lent hundreds of millions of dollars to Neumann. WeWork disclosed Neumann's $500 million personal line of credit from JPMorgan, UBS, and Credit Suisse, $380 million of which had been drawn down. The CEO had another $98 million from JPMorgan in the form of mortgages and other loans. WeWork was part of Dimon's plan to supplant the duopoly of Goldman Sachs and Morgan Stanley running tech's hottest IPOs.

Later that Sunday, Neumann had dinner with Bruce Dunlevie, one of WeWork's earliest directors and a partner at the investor Benchmark Capital, to discuss his options. Dunlevie and Dimon had been supporting Neumann's desire to remain as CEO, but no more: Dunlevie broke the news to Neumann at that dinner that he was siding with SoftBank. He wanted Neumann out. A representative for Benchmark Capital declined to comment.

On Tuesday, September 24, as Neumann's fate hung in the balance, WeWork's board assembled at JPMorgan's Madison Avenue headquarters. The octagonal building found itself at the center of corporate America's biggest debacle once again after hosting last-ditch efforts to salvage Bear Stearns before the 2008 financial crisis hit its nadir. On floors that towered over Grand Central Terminal, WeWork's board met for hours to discuss what to do. By the time the members emerged from the skyscraper's granite walls, Neumann had been voted out. In the end, Neumann voted against himself.

He would step down and become nonexecutive chairman. He had lost control of the company and watched his voting power reduced to three votes a share, giving him a minority of votes. He can nominate only a minority of directors.

In a statement, Neumann told employees that "since the announcement of our IPO, too much of the focus has been placed on me."

Read more: Adam Neumann is out as WeWork's CEO, but that's no 'silver bullet': VCs and proptech experts think it will take cutting passion projects and cleaning house to right the ship

The board named the WeWork executives Sebastian Gunningham and Artie Minson to replace Neumann, and the company began considering such unthinkable options such as slowing its growth, cutting thousands of employees to focus on its core business of renting office space, and getting rid of side businesses such as Rebekah Neumann's school to control costs and — perhaps — restore investor confidence. When asked recently to respond to concerns about its business model, the company said it intended to fully honor its lease commitments.

The company began to formalize talks for a renegotiated loan of about $3 billion, which was expected to require the raising of additional equity.

The Economist publicly wondered whether anything could be done to halt what it called "WeWork's slide towards possible bankruptcy."

By Thursday, SoftBank was talking about another injection of $1 billion.

Additional reporting by Meghan Morris, J.K. Trotter, Meredith Mazzilli