You don't need to parse the ulib groups to do this. ULib automatically assigns groups to teams (or that might be ULX) either way, just try this...
function ChatTags(ply, strText)
chat.AddText(Color(0,0,0,255), "[", team.GetName(ply:Team()), "]", team.GetColor(ply:Team()), ply:Nick(), Color(255,255,255,255), ": ", strText)
return true
end
hook.Add("OnPlayerChat", "Tags", ChatTags)
my only concern is that since you are intercepting chat and returning another value with true will this not break all other chat hooks?
nevermind. This is the client version not the serverside version. The above code should work fine for what you need.