SACRAMENTO — A bill that would have let communists legally work in California government was withdrawn Wednesday after the sponsor said he learned it caused veterans and Vietnamese-Americans “distress and hurt.”

Assemblyman Rob Bonta, a Democrat from the San Francisco Bay Area city of Alameda, announced he was shelving the bill and apologized to veterans and people who fled the communist regime in Vietnam.

His bill, AB22, would have repealed part of state law enacted during the Red Scare of the 1940s and ’50s when fear that communists were trying to infiltrate the U.S. government was rampant. The Cold War-era law made belonging to the Communist Party a fireable offense for public employees.

Bonta said such provisions have since been ruled unconstitutional. Under his bill, employees could still have been fired for belonging to organizations they know advocate overthrowing the government by force or violence.

The Assembly narrowly approved the bill last week. Some Assembly Republicans spoke forcefully against the measure before voting against it.

Assemblyman Randy Voepel, a Southern California Republican representing the 71st District in San Diego and Riverside counties and who fought in the Vietnam War, said communists in North Korea and China are “still a threat.”

“This bill is blatantly offensive to all Californians,” said Assemblyman Travis Allen, a Huntington Beach Republican. “Communism stands for everything that the United States stands against.”

Assemblyman Ash Kalra, one of Bonta’s fellow Democrats from San Jose, praised his Alameda colleague for shelving the bill, saying it caused pain for many of his constituents.

In Orange County, Little Saigon leaders protested the legislation, with Westminster Mayor Tri Ta saying the community felt betrayed. Little Saigon — including Garden Grove, Westminster and parts of Santa Ana, Fountain Valley and Huntington Beach — is largely populated by refugees or relatives of refugees who fled their homeland after the fall of Saigon in 1975 to communist forces.

The Register contributed to this report.