The manner in which part of Amazon’s HQ2 was recruited to New York City, and then lost to it, featured all the key players behaving like a negative stereotype of themselves: Gov. Andrew Cuomo was autocratic, New York City Mayor Bill de Blasio was incompetent, Amazon was high-handed and conceited, and local legislators were preening and petty.

Amazon, Cuomo and de Blasio should have been able to anticipate and mollify some of the opposition that emerged. Instead, a company that was looking beyond its native Seattle precisely because of local displeasure with choking traffic and unaffordable housing didn’t think that New York City – already obscenely expensive and bursting at the seams – might have the same concerns. And de Blasio and Cuomo somehow didn’t think of this either.

Had the company, the governor and the mayor worked out a deal in which Amazon offered some investment in local affordable housing development and transit infrastructure upgrades, they would have mitigated the blowback and the company would be packing its bags for Queens. Instead, elected officials from the city and state on both sides simply ignored New York’s underlying problems that undermined the deal. As Matthew Yglesias of Vox has explained, for most workers in a city with a housing shortage, attracting a big high-paying employer isn’t beneficial: The average New Yorker would get higher costs of living without higher wages. So it made a certain sense for New York to reject Amazon. But that’s only if you accept a failed housing policy as a premise. What if, instead, Cuomo, de Blasio and the plan’s opponents in the City Council and state Legislature had developed a comprehensive plan for creating so much new housing through upzoning and affordable housing investment that it would more than absorb the new Amazon employees? We’ll never know, because instead everyone just acted like the worst possible versions of themselves. Here’s a rundown of how:

Amazon has built a reputation for demonstrating the worst impulses of fellow tech giants such as Facebook and Uber: haughty, secretive and disrespectful of democratic law. Should it come as any surprise that a company that initially grew by avoiding state and local sales taxes would disdain being subjected to critical City Council hearings? That a company that beat back a small tax in Seattle to address the city’s Amazon-induced homelessness crisis and is known for overworking its employees would refuse to compromise with unions and progressive elected officials?

Their shock was palpable when Amazon executive Brian Huseman noted last month at the City Council: “We were invited to come to New York.” But Huseman neglected a relevant fact: The company insisted that the terms of the invitation were made in secret. He can hardly blame officials who were cut out of the process for publicly raising concerns after the deal was announced – they had no chance to do so privately beforehand. Amazon should have known that a union town would demand unionization at fulfillment facilities, for instance. But, like other tech companies that have been shocked and enraged when their secretive, greedy behavior causes a backlash, Amazon was so conceited that it was caught off-guard.

Gov. Andrew Cuomo did what he does: He meddled in New York City’s affairs, assumed he would be thanked for it, sided with big business against his party’s progressive base, and exploded with rage when the perfection of his plan was questioned. Cuomo has made a habit of intruding on the city without soliciting input from people who, unlike him, actually live there, such as in 2015 when he unilaterally decided, without consulting the mayor, that the subways would shut down in anticipation of a snowstorm. This time, he cut local representatives and neighborhood activists out of the deal by making an end run around the Uniform Land Use Review Procedure. It was a raw display of his imperious style. Cuomo was completely unwilling to show even the slightest sign of respect for local power brokers, or New Yorkers fearful of exacerbated gentrification, much less to offer them a compromise. Instead, when he faced resistance, the governor lost his infamous temper and tried to berate his critics into submission. In a situation that called for compromise and consideration, Cuomo was unable to deviate from his overbearing style. The casualty was his own agenda.

Mayor Bill de Blasio, as the one local elected official involved in the talks – and as a self-styled progressive leader – should have played the role of pushing Amazon to make concessions that would ameliorate local fears of gentrification, displacement, and 7 trains that are even harder to get on in the morning. But he couldn’t be bothered. De Blasio has developed a reputation for his own sort of arrogance. It’s different from – almost an inversion of – the governor’s bullying style. De Blasio seems to think he’s too good for doing the nitty gritty dealmaking of his day job. Instead of going to the office, he goes to Iowa and New Hampshire to raise his national profile. In this case, de Blasio did little to win the City Council’s support for a plan he helped craft. Despite being a lifelong New York Democratic political operator who has made economic equality his signature issue, de Blasio apparently didn’t expect the Teamsters and the Retail, Wholesale, and Department Store Union to object to New York rolling out the red carpet for Amazon. When he could have been convening stakeholders and hammering out a revised agreement, de Blasio was busy trying to drum up nonexistent interest in a presidential bid. The mayor lived up to his reputation for ineffectual governance, borne of pompous detachment.

In late 2017, City Councilman Jimmy Van Bramer and state Sen. Michael Gianaris, both of whom represent Long Island City, signed a letter urging Amazon to pick New York City for its HQ2. Yet, once they got their wish, Van Bramer and Gianaris emerged as implacable foes of the company’s relocation. They might say it was over the subsidies offered, but that’s ridiculous. When they sent the letter, it was publicly established that Amazon was seeking generous subsidy offers. The vast majority of the tax breaks would go to any company that created jobs under an existing program – which neither Van Bramer nor Gianaris had made a point of trying to repeal.

It seems they were mad for the same reason they had signed the letter in the first place: They wanted credit for what was in their personal political interest. At first, they thought that was credit for bringing Amazon to New York. If they couldn’t get credit, the next best thing would be to hold up Amazon for something they could show their constituents, such as jobs promised specifically to residents of the adjacent Queensbridge NYCHA development. And they’d rather throw away the jobs and tax revenue than let something good happen if there was nothing in it for them personally. When the deal was made without their involvement, they couldn’t claim credit for bringing Amazon or even for getting something out of it. So, they threw a tantrum. The presidents of the associations of neighboring housing projects accurately accused these politicians of “grandstanding.”

Self-interested, grandstanding local politicians is to be expected and it de Blasio and Cuomo should have planned accordingly. Allowing local representatives to demand concessions from companies seeking large public subsidies is part of the political process. It’s how a community that will bear the brunt of downsides to regional economic growth is compensated for its trouble. But Cuomo was too peremptory and Blasio too inept or disengaged to work with local representatives.

“All of those electeds should have been able to work this out,” said one former New York City city planning official, who requested anonymity to speak frankly. “This debacle should be studied at planning and business schools for how not to do an economic development project. I’m still shocked at the gross incompetence and arrogance on all sides.”

Correction: The description of the anonymous source at the end of the story has been updated to more accurately reflect the individual.