In a three-tweet policy announcement Wednesday morning, President Trump promised to institute a ban on transgender service-members. The president claimed that the reason for this change was the need to “focus on decisive and overwhelming victory,” which was apparently made impossible by the “tremendous medical costs and disruption that transgender in the military would entail. Thank you.”

Senator John McCain, long a proponent of decisive and overwhelming victory in many places around the globe, swiftly condemned the change. Echoing many others reactions, Senator McCain said, “We should all be guided by the principle that any American who wants to serve our country and is able to meet the standards should have the opportunity to do so—and should be treated as the patriots they are.” The Israeli Defense Forces, whose commitment to decisive and overwhelming victory the President has publicly admired, also deploys transgender service members. And it was also quickly pointed out that the annual medical costs attributable to transgender service-members constituted only a tenth of what the Department of Defense already spends on medication for erectile dysfunction.

Now, to be sure, tweets are not executive orders. One reporter claimed to overhear someone in the Pentagon muse, “We’re taking orders via Twitter now?” And the answer is, of course, no. The military is so far not treating the tweets as an order but is waiting for a formal directive. But assuming the president makes good on his tweets and directs Secretary Mattis to revise departmental policy to ban transgender service-members, will he succeed? The answer is also probably no.

For one thing, the president sorely underestimates the density of the Department of Defense’s bureaucracy. Secretary Carter’s policy change last June allowing transgender service came after years of study and review. In addition to the operative departmental instructions and orders, the policy change has its own website, informational video, and commander’s handbook. As anyone who has worked in the Department of Defense knows, change requires a lot of paperwork. And a change on this scale, which according to the RAND Corporation would result in the discharge of anywhere from 2,000 to 10,000 active duty and reserve members, requires more than 140 characters.

But the overriding reason that this policy change is likely to fail is the courts. Those 2,000 to 10,000 service members who face being dropped from the rolls, as well as the thousands more who will be denied the opportunity to serve, will—and should—sue. They likely will win. And ironically it is the largely failed effort to invalidate the previous ban on gays and lesbians serving in the military under Don’t Ask Don’t Tell that makes victory this time all the likelier.

I by no means intend to suggest that a legal fight will be easy or that victory is a foregone conclusion. Since the 1970s, and particularly after the abolition of the draft, the Supreme Court has relied upon the “separate society” doctrine when evaluating the constitutionality of laws dealing with the military. Under the separate society doctrine, the military is deemed to be a culture within the culture, defined by an overriding ethos of obedience, solidarity, and readiness to fight. Hence, what the government may not do to the society at large—say prohibit the wearing of yarmulkes or impose the death penalty without a trial by jury—is permissible in the military. And courts broadly defer to the political branches’ judgments about what is permissible on the theory that federal judges are ill-equipped to know what this separate society really needs to fight wars.

At first blush, a presidential directive barring transgender service-members would seem to fall into this area of heightened (near absolute) deference. If the President determines that the sacrifices made by transgender service-members are unwelcome in the American military, it may be unwise and discriminatory, but it is not unconstitutional because Commander-in-Chief is allowed to be unwise and discriminatory with the military. But the first blush, in this case, would be wrong.

The principle reason is that the president and Congress cannot, even when acting together on issues relating to the military, discriminate invidiously. It was a case upholding gender discrimination that established this principle. In 1981, in Rostker v. Goldberg, the Supreme Court said it was constitutional for Congress to require men, but not women, to register for the draft. But in doing so, the Court started from the foundational premise that Congress is not “free to disregard the Constitution when it acts in the area of military affairs” and is not free to discriminate by “arbitrarily choosing to burden one of two similarly situated groups, such as would be the case with an all-black or all-white, or an all-Catholic or all-Lutheran, or an all-Republican or all-Democratic registration.” It was only because the political branches had engaged in an extensive deliberative process, which led them to conclude that men and women were not similarly situated, that women could be exempted from the draft.

The courts, in other words, do not defer blindly to any decision the political branches make about the military. They defer to the judgments the political branches make about the evidence for or against a given policy. But for there to be judgment, there must be some deliberative process from which a judgment was made.

Which leads to the three decades of litigation surrounding the exclusions of gays and lesbians from the military. The constitutional challenges to the military’s exclusion of gays and lesbians never really reached the Supreme Court. The closest the Court ever got was in 2006, when a coalition of law schools challenged a law that conditioned the universities’ federal funding on their permitting the military to recruit on campus. The law schools claimed that the military’s prohibition of gays and lesbians from serving violated their anti-discrimination rules for on-campus recruiters and hence their First Amendment rights to association. The Supreme Court unanimously dismissed this challenge out-of-hand, without evaluating the constitutionality of Don’t Ask Don’t Tell, because it was simply not a good First Amendment case.

But the issue arose repeatedly in the Circuit Courts of Appeal. Then-Judge Anthony Kennedy wrote the first major decision on the issue in 1980, upholding the military’s discharge of a sailor convicted of sodomy. In an opinion that in many ways previews his opinion striking down Texas’ anti-sodomy law twenty-four years later in Lawrence v. Texas, Judge Kennedy ruled that whatever rights gays and lesbians might have against discrimination in the society at large, the military’s conclusion that “homosexual conduct” could be disruptive within the military’s culture was entitled to deference. Focusing on “conduct,” Judge Kennedy reasoned that the military prohibited and required all sorts of things that would be unconstitutional for society at large. A prohibition on gay sex was just another one of those things and the courts were not in a position to second-guess the military’s judgement about what was necessary to maintain good order and discipline within the military’s separate society.

And this focus on “conduct” formed the basis of the judicial decisions on the issue throughout the 1980s and early 1990s. In case after case, Circuits around the country upheld the discharge of service members, who had committed sodomy, based upon the idea that they had engaged in a kind of prohibited conduct. Judge Robert Bork even took the opportunity in one of these cases to write more broadly on why it was constitutional to prohibit sodomy more generally, applying a kind of reasoning that the Supreme Court would adopt two years later in Bowers v. Hardwick, only to ultimately reject it in Lawrence v. Texas in 2004.

A trickier problem arose with service members who self-identified as gay or lesbian but promised sexual abstinence while in the service. Most circuits recognized the non-discrimination principle that the Supreme Court laid down in Rostker, but reasoned that discrimination based upon sexual orientation was not entitled to special scrutiny because of Bowers v. Hardwick. And so, applying rational basis scrutiny in the context of the military, a service-member’s acknowledgement that he or she was gay reflected a “desire and propensity to engage in homosexual conduct,” which was deemed a rational reason to prevent the conduct itself.

This reasoning had its obvious flaws. The Ninth Circuit rejected these prophylactic arguments and created a circuit split that the Supreme Court never resolved. And as Judge Patricia Wald wrote, dissenting in an en banc D.C. Circuit case on the question, “the government and the majority seem to be saying that gay service members—unlike heterosexuals—must be presumed incapable of controlling their sexual ‘desires’ in conformity with the law.”

Then came Don’t Ask Don’t Tell. After an abortive effort to repeal the general ban on gays and lesbians serving in the military, President Clinton signed 1994 NDAA, which permitted only closeted homosexuals to serve. Over the eighteen years it was in place, Don’t Ask Don’t Tell not only prohibited gay sex, it required the military to conduct a series of bizarre administrative hearings in which service-members suspected of “acting gay” could save their military careers by effectively apostatizing their homosexuality.

Efforts to challenge the constitutionality of the law uniformly failed. And the reasons why they failed are precisely why those who might challenge President Trump’s ban on transgender service-members are likely to succeed.

Every Circuit Court of Appeals upheld the law as constitutional, even after the Supreme Court began invalidating anti-gay laws as unconstitutional in 1996. Very often, the Circuit courts were divided. But even judges who expressed misgivings about the Don’t Ask Don’t Tell policy nevertheless upheld it for the simple reason that Congress and the President had done their due diligence. Following the Supreme Court’s rule in Rostker, the circuits were unanimous that invidious discrimination was prohibited. But, however unwise, Don’t Ask Don’t Tell had too much of a paper trail to be called invidious.

The most significant and influential of these cases was an en banc decision from the Fourth Circuit two years after Don’t Ask Don’t Tell went into effect. In upholding the law, Chief Judge Harvie Wilkinson recounted:

In the first seven months of 1993, both the Executive Branch and Congressional committees engaged in an extensive review of the military’s policy. The Senate Armed Services Committee held no less than nine days of hearings, including a field hearing at the Norfolk Naval Complex, taking testimony from nearly fifty witnesses. The House Armed Services Committee held five days of hearings. Witnesses who appeared at these hearings represented a broad range of views and backgrounds. They included: the Secretary of Defense and the Chairman of the Joint Chiefs of Staff; military and legal experts; enlisted personnel, officers and senior military leaders; and activists supporting and opposing the military’s policy. At the same time, the Department of Defense conducted its own exhaustive review. It convened a military working group composed of senior members of each service, commissioned a study by the Rand Corporation, initiated regular consultations with the Joint Chiefs of Staff and leaders of each service, studied the history of the military’s response to social change, and consulted legal experts. General Colin N. Powell described the consideration by the Joint Chiefs of Staff in this way: “We have challenged our assumptions. We have argued with each other. We have consulted with commanders at all levels.” Assessment of the Plan: House Hearings, at 31.

In a word, the Courts did not simply defer to the President’s unilateral decision to discriminate. They evaluated the record, which showed the political branches coming to a judgment based upon a regular deliberative process. They may have made the wrong decision. President Clinton’s endorsement of Don’t Ask Don’t Tell, like his signing the Defense of Marriage Act, is certainly not a legacy that has not aged well. But the policy bore all the hallmarks of rational lawmaking. And that regularity, in turn, compelled the courts to afford broad deference to the political branches’ collective judgment about what was necessary to preserve good order and discipline within the military’s separate society.

By contrast and to borrow Chief Judge Wilkinson’s phrase, President Trump’s early morning tweet storm did not draw “on the combined wisdom of this exhaustive examination in the Executive and Legislative branches.” President Trump is attempting to reverse a policy that was based on the very due diligence that compelled courts to uphold Don’t Ask Don’t Tell twenty years ago. Indeed, Secretary Carter’s description of the deliberative process that led to the current transgender policy mirrors, nearly point by point, the deliberative process that led to Don’t Ask Don’t Tell:

The leadership of the armed services — together with personnel, training, readiness, and medical specialists from across the Department of Defense — studied the available data. We also had the RAND Corporation analyze relevant data and studies to help us with our review. And we got input from transgender servicemembers, from outside expert groups, and from medical professionals outside the Department.

Not only were President Trump’s tweets not based upon any study by the RAND Corporation, according to one Trump administration official, the reason for the change was the desire to have a wedge issue that could help the beleaguered President’s poll numbers in the 2018 mid-terms:

This forces Democrats in Rust Belt states like Ohio, Michigan, and Wisconsin, to take complete ownership of this issue. How will the blue collar voters in these states respond when senators up for re-election in 2018 like Debbie Stabenow are forced to make their opposition to this a key plank of their campaigns?

What is more, unlike Don’t Ask Don’t Tell, any effort to exclude transgender service-members is being done without the support of Congress. In fact, earlier this month, the House voted down an amendment to the 2018 NDAA that would have prohibited the Department of Defense from paying for gender reassignment surgery or hormone therapy.

And unlike the treatment of gays and lesbians, a ban on transgender service-members cannot be justified as a regulation of “conduct” and those who have a “propensity” to engage in prohibited conduct. The ban on transgender service-members simply burdens the kind of group identity the Supreme Court identified in Rotsker, like blacks, Catholics, and Republicans, which bears no obvious relevance to the individual’s capacity to serve their country.

If President Trump presses forward with his transgender ban, it is likely to face a similar fate as his Muslim ban and for the same reasons. As Jack Goldsmith first observed back in February, the president’s authoritarian style coupled with his tendency to be “thin-skinned, uninformed, and impulsive,” has weakened the presidency to a degree unmatched since the post-Watergate era. And here, the Trump Administration’s apparent allergy to process and deliberation is likely to again deprive it of the presumption of regularity, indeed significant deference, that the courts ordinarily would afford the President’s policies relating to the management of the military.

Like the immigration power, it is difficult to name an area of executive power that has historically been less constrained by judicial review. It is remarkable how blindly the President will have forfeited the vast reservoir of discretion that the executive branch has earned over the last fifty years. But that is clearly what should happen here and very likely what will happen. Under the Supreme Court’s decision in Rostker, the political branches may discriminate in the military in ways that would be unacceptable in ordinary life. But they must do their due diligence first. That attention to process made Don’t Ask Don’t Tell impervious to constitutional attack for two decades. And Secretary Carter’s attention to process in allowing transgender service-members to serve openly is likely to prove itself to be as impervious to President Trump’s most recent tweet storm.