The FBI was watching, but at the outset didn't know who, or where, Alhaggagi was. Until he mentioned more ideas.
"He wanted to plan to start a huge fire in an area near where he lived and he specifically mentioned the Berkeley Hills as a potential target," Hasib told the court in December. "That was our first indication that we were dealing with someone in the Bay Area."
Several of Alhaggagi's alleged communications identified San Francisco as a good target for an attack because the city is known for its acceptance of LGBT people.
Hasib quoted from one of the messages: " 'I live close to San Francisco. That's like the gay capital of the world. I'm going to handle them right. LOL,' meaning laughing out loud. 'I'm going to place a bomb in a gay club. ... I'm going to tear up the city. ... The whole Bay Area is going to be up in flames. My ideas are genius. LMAO,' meaning laughing my ass off.' "
Alhaggagi was represented at the Dec. 14 hearing by an assistant federal public defender, Hanni Fakhoury, who did not dispute the government's evidence.
"There is a bit of a disconnect between Mr. Alhaggagi's words and his actions," Fakhoury told the court. He said the ultimate issue was how much of what his client said was "very stupid and very inappropriate and very disturbing puffery and how much of it was actually intended to be acted out."
The defense stated that Alhaggagi was born in Lodi, grew up in the East Bay and attended Berkeley High School. Part of the non-terrorism charge against him involves using a stolen credit card and a fraudulent address to steal $4,932 in clothes from an online retailer.
"To me that doesn’t smack as someone who is a radicalized jihadi," Fakhoury said. "This is a young man who wants to have some nice clothes."
While he was using fraudulent credit card information to steal clothes, Alhaggagi was allegedly chatting about leveraging those skills toward terrorism in the Bay Area.
He told the FBI source that he had access to equipment "to make the cards and checks," according to the prosecution at the December detention hearing. "I'm trying to make bombs. I'm going to need funds."
Alhaggagi allegedly told the FBI's source that he planned to work for a local police department and steal weapons. Agents started canvassing Bay Area police departments.
"They learned that Mr. Alhaggagi had submitted an application to the Oakland Police Department," just a few days earlier, Hasib said.
The source introduced Alhaggagi to an undercover agent posing as an al-Qaida-trained fighter.
"His plan was to blow up a car bomb at an unidentified gay nightclub in San Francisco and then place backpack bombs around the East Bay," Hasib said. "He also took the undercover around the UC Berkeley campus and identified buildings, including dorms, where he wanted to plant backpack bombs."
The undercover agent reportedly convinced Alhaggagi to put anything he planned to use in attacks in a storage locker, which in reality was closely monitored by the FBI. Alhaggagi allegedly stored several backpacks there, then suddenly stopped communicating with both the initial source and undercover agent.
The FBI continued close surveillance and arrested Alhaggagi late last year.
Prosecutors also say time he spent in Yemen from 2002 to 2009 -- from when he was approximately 7 years old until he was about 14 years old -- "gives us great concern," as well as trips that Alhaggagi has reportedly taken to Saudi Arabia.
But Alhaggagi's attorney, Mary McNamara, who took over his defense in March, paints a different picture from the evidence presented at the detention hearing.