Neither upon nor despite is great here, but upon is less bad. After would be better because it agrees with the resultative aspect of were on her side. Upon is usually used for eventative focus, and that is unnecessary in the OP's example. "However, upon learning that Terry was the defense lawyer in this court case, they immediately changed to be on Sally's side."
Despite is a nonstarter here. Despite is used to introduce a condition that works against, but fails to change, the actual outcome.
I love to surf. I went today despite the iffy conditions.
I love to surf, but I had to work. I didn't go today despite the
In the OP's example, the introduced condition, Terry, did change the outcome, so despite can't be used there.
However, if you make it clear that everybody hated Sally but that they were already on her side, then it could work.
All the people hated Sally; but they were on her side despite learning that Terry was the defense lawyer in this court case.