The Supreme Court upheld President Trump’s ban on travel from five mostly Muslim nations this week, finding that the ban had a “legitimate grounding in national security concerns” and was thus constitutional. Trump celebrated by calling opponents of the ban “hysterical.”

But the biggest threat to the United States today does not come from immigrants, refugees or the immigration system but from extremists of all races and religions within our own borders. The court’s conclusion therefore isn’t just wrong or unjust — it is downright dangerous.

What is fundamentally at the heart of both the ban and the court ruling is a tragically outdated understanding of how modern terrorism networks recruit for and implement attacks on U.S. soil.

Whereas the al-Qaeda of the early 2000s once exploited holes in the U.S. immigration system to commit attacks, today’s terrorist networks have realized that those loopholes have long since been closed by immense advances in the U.S. vetting and immigration procedures. Al-Qaeda’s successors, such as the Islamic State and al-Shabab, now depend heavily on reaching potential recruits in our own country, and today they target their audiences through online video propaganda and social media. These efforts are not the least bit affected — and therefore cannot be stopped — by the travel ban.

The ban’s focus on Muslim-majority countries is also woefully out of touch with the terrorist threat to the United States. The predominant content of terrorist recruitment videos isn’t religious verse because recruits for terrorist networks aren’t the faithful. Our partners at the University of Chicago’s Project on Security and Threats released a report in 2017 that catalogued 112 individuals indicted on charges of Islamic State-related offenses by the Department of Justice between 2012 and 2014. They found that a majority of the individuals indicted were in fact not pious or born into Muslim families before being recruited but were radicalized through videos centering on a specific narrative: that the United States as a nation is and will forever be an irretrievably racist, unjust and unwelcoming place for minorities. As proof, the militant group’s videos point to long-standing violent racist groups such as the Ku Klux Klan and the country’s history of prejudice against Catholics, Jews, African Americans and, now, Muslims.

To put it another way, modern terrorist recruitment networks no longer hate us because we’re free, they hate us — in part — because many Americans are not free. By engaging in the demonization and “othering” of Muslims and implementing the president’s anti-Muslim campaign pledges, this travel ban mimics the Islamic State’s depiction of the United States as selectively hostile to people of Muslim faith and bolsters their recruitment efforts. All this under the banner of protecting U.S. national security.

The court had ample time and resources to discover what most veteran national security leaders already know: The travel ban, as described by former National Security Agency and CIA director  Michael Hayden, is “unwarranted, it was unnecessary, and it was dangerous.” Speaking alongside Hayden at an event in April sponsored by our organization, Only Through US, former defense secretary Chuck Hagel agreed that the process was deeply flawed and that “the facts just don’t bear out that immigrants are wreaking havoc and terror on Americans since 2001 … by any metric or any standard of application that you’d apply to this issue.”

It is telling that 52 former national security leaders — including five former CIA directors, two former defense secretaries, two secretaries of state and several other senior officials charged with keeping Americans safe over the last three administrations — wrote a letter to the court outlining the false national security claim to the travel ban. The leaders described that the travel bans 1.0, 2.0 and 3.0 did not emerge from a careful interagency review by national security and foreign policy offices, and that the third ban “so closely mirror[ed] the original ban in form and substance that any additional ‘process’ the Government now cites cannot dispel this original sin [of the first].”

Some of the brief’s authors were current on active intelligence regarding credible terrorist threat streams directed against the United States as recently as one week before the issuance of the original Jan. 27, 2017, executive order. By contrast, the sole amicus brief by national security figures in support of the ban included a paltry six names, such as Frank Gaffney Jr., the founder and president of the Center for Security Policy (listed by the Southern Poverty Law Center as an anti-Muslim extremist group), but not a single Cabinet-level official.

The majority’s opinion agreed that the administration had engaged in a serious interagency review of risks posed by outside countries to the United States — although those results have never been made public. However, as the dissent noted, it is utterly irresponsible to consider any version of the travel ban without placing it within the context of candidate Donald Trump’s campaign promise to institute “a complete and total shutdown of Muslims entering our country,” his assertion that “Islam hates us” and his moves to stack his administration with virulently anti-Muslim and anti-immigrant figures (one of whom, Frank Wuco, was explicitly mentioned in Justice Sonia Sotomayor’s dissent) such as Stephen Miller, an architect of the first version of the ban, and Secretary of State Mike Pompeo, who have stated that Islam poses a threat to Western civilization and that American Muslims are potential threats by virtue of their religion. Individuals with such a record of anti-Muslim statements are fundamentally unqualified to undertake any review about potential threats posed by Muslim-majority countries to the United States.

We have worked on different sides of the United States’ response to 9/11: one of us in Iraq, Guantanamo Bay and the Pentagon advising three defense secretaries, and the other serving our Iraqi coalition partners seeking refuge from targeted violence at the height of the war. Whether listening to inmates at Guantanamo Bay describing how recruiters influenced them with tales of U.S. injustice or watching as we turned our backs on Iraqis who laid their lives on the line for us, we both developed a deep appreciation for the gravity of our obligations as Americans — to justice, to humanity and to our own values.

Those obligations today mean building sober policy based on evidence, not fear, as well as fostering meaningful partnerships with our allies abroad. Trump’s travel ban and the Supreme Court ruling undermine the United States’ ability to meet those obligations. The ban distracts from genuine threats and is driven by prejudice and fear — two emotions that neither make for good policy nor keep us safer at night.

The Muslim travel ban is just the latest in a long string of factless, fear-based policy choices that collectively have made us less safe, less faithful to our values and more isolated as a country. That the ban was upheld Tuesday by the highest court in the land is more than disappointing; it places us squarely, and ever more vulnerably, on the wrong side of history.

Read more: