The man who shot dead three people at a UPS warehouse in San Francisco filed a grievance complaining that he was working excessive overtime, a union member has said.
Joseph Cilia, a Teamsters Union official, said Jimmy Lam's complaint, filed in March, requested that United Parcel Service relieve him of working overtime.
But Mr Cilia said Lam was not angry and he could not understand why he would open fire on his colleagues at a morning meeting on Wednesday.
Lam targeted three fellow UPS drivers, Mr Cilia said. Two other drivers who were wounded had been released from the hospital, he added.
Police say Lam killed himself after the shooting, which happened inside one of the company's packing buildings.
Workers fled frantically into the streets shouting "Shooter!" and police swarmed in, authorities and witnesses said.
Amid the barrage of gunfire, some peoples sought refuge on the roof of the four-storey building, while others ran outside and pounded on the windows of a bus, witnesses said.
"They were screaming Go! Go! Go!," said Jessica Franklin, 30, who was on her way to work when the bus made a regular stop in front of the UPS building.
"As they got on the bus, they were all ducking."
Two other UPS employees were wounded in the shooting that prompted a massive police response in one of the city's industrial neighbourhoods, about two miles from the city centre.
Police have not yet released victims' names but families and friends identified one of the people killed as 46-year-old Mike Lefiti, a UPS driver.
Mr Lefiti's cousin, Mack Toia, told KGO-TV he was waiting to pick up Mr Lefiti when he heard shots. He left his van and saw his cousin sprawled on concrete behind a gate.
"The police officers were right on the scene just like that. I got to touch him, but I couldn't hug him," Mr Toia said.
"They just pushed me away because they were trying to resuscitate him."
Mr Toia said he was able to tell his cousin he loved him.
Co-worker Isaiah Miggins said he saw Mr Lefiti, known as "Big Mike", as he arrived for work just before 9am, a few minutes before the shooting started.
"He was a joyful man. Always happy," Mr Miggins said.
On social media, heartbroken family members of Mr Lefiti recalled him as a warm-spirited man devoted to his children and family.
A photo on his Facebook page shows Lefiti in his brown UPS uniform holding a trophy. He also posted photos of his UPS lorry and an award for 15 years of service to the company in 2015.
Tech worker Raymond Deng, 30, who lives opposite the warehouse, said he heard up to eight gunshots.
"They were all in rapid succession," he said. "It was like tat, tat, tat, tat, tat, tat, tat."
Police arrived in minutes.
"This was a frightful scene," assistant police chief Toney Chaplin said.
He said officers found two victims outside and others inside and pulled the wounded to safety as they confronted the gunman, who was armed with an "assault pistol".
"The suspect put the gun to his head and discharged the weapon," Mr Chaplin said.
San Francisco mayor Ed Lee condemned the violence and praised authorities for a "very proactive response."
"It could have been worse," he said. "Lives were saved today."
It was not immediately clear how many employees were at the building, but UPS said the warehouse employed 350 people.
UPS driver Marvin Calderon told KNTV that he recognised the gunman as a fellow employee but did not know him personally.
"I just started running out like crazy, like I've never run before," he said.