As we contemplate Trump’s declaration banning transgender Americans from serving in our armed forces, it is useful to think back on our nation’s history with gays and lesbians serving in the military.

In all of our nation’s wars up until World War II, prospective soldiers were not asked about their sexual orientation. Although the Code of Military Justice prohibited any member of the armed forces to engage “in unnatural carnal copulation with another person of the same or opposite sex” – meaning oral or anal sex – there was no special rule directed at homosexuals. And although military officials in World War I were well aware of the presence of homosexuals in the ranks, they almost never court-martialed members of the military for consensual sodomy – whether same-sex or opposite-sex.

In the lead-up to World War II, however, the Selective Service for the first time instituted a policy designed to weed out prospective soldiers who were deemed psychologically unsuited for military service. Although the policy was not specifically directed at homosexuals, those charged with enforcing the policy concluded that homosexuals by definition fell within the category of those who were “psychologically unsuited” for military service.

This posed an almost impossible task for those charged with carrying out the screening. How were they to determine who was a homosexual? At induction physicals, millions of men were asked whether they had ever had homosexual urges or experiences. The exercise was largely pointless, because gay men who were determined to serve their country simply lied about their sexual proclivities.

It is impossible to know precisely how many homosexuals joined the military in these years, but the best estimates suggest that more than half-a-million gay men and lesbians managed to serve their nation in the armed forces during World War II.

In truth, the military was more interested in recruiting soldiers than in excluding homosexuals, and gay men and lesbians found little to prevent them fighting our enemies in the war. On one occasion, General Dwight Eisenhower asked a WAC sergeant to remove the lesbians in her battalion. The sergeant responded: “Yessir. If General Eisenhower pleases I will be happy to do this investigation. . . . But, sir, it would be unfair of me not to tell you, my name is going to head the list. You should also be aware that you’re going to have to replace all of the file clerks, the section heads, most of the commanders, and the motor pool.” To which Eisenhower replied: “Forget the order.”

As the war drew to a close, though, and as gay and lesbian soldiers suddenly became dispensable to the military, the witch hunts began. Suspected lesbian and gay soldiers were now called in and cross-examined about their sexual feelings and practices and compelled to disclose the names of their sexual partners. It was not unusual for them to be physically abused, subjected to public humiliation, and committed to hospital psychiatric units.

In Toyko, some 500 women soldiers were summarily discharged because of accusations of homosexuality. In one particularly tragic incident, recalled by a member of the WACs, the military authorities “called up one of our kids – Helen, who had voluntarily served her nation in the War. They got her up on the stand and told her that if she didn’t give names of her friends they would tell her parents she was gay. She went up to her room on the sixth floor and jumped out and killed herself. She was twenty.”

Almost half-a-century later, after a heated and sometimes bitter public debate, in 1993 President Bill Clinton announced a change in policy – the military would no longer inquire into the sexual orientation of members of the armed forces, but it could still discharge service members who revealed their sexual orientation to others. This egregious “compromise” of “Don’t Ask/Don’t Tell” remained in place for the next 17 years, causing grievous harm to the lives of gay and lesbian soldiers and to the armed services themselves.

In his 2010 State of the Union Address, President Barack Obama promised to work with Congress “to finally repeal the law that denies gay Americans the right to serve the country they love.” With the support of the Joint Chiefs of Staff, who finally conceded that there was a low risk of disruption if gays, lesbians, and bisexuals were permitted to serve openly in the military, Congress by an overwhelming margin repealed Don’t Ask/Don’t Tell and finally gave all Americans “the right to serve the country they love.”

Now, President Trump, acting out of the same ignorance, bigotry, immorality and betrayal of fundamental American values that led to decades of ugly discrimination against gays and lesbians, has banned transgender Americans from serving “the country they love.”

This is a shame and a tragedy for our nation. We will, of course, eventually overcome this national embarrassment and put this moment of ugliness behind us. But it is a disgrace that we should even need to do so.