This is not the correct fix, but a correct fix would be to remove this addon (and potentially rewrite it properly). Sadly, I don't have the authority to do that, so, meanwhile, this fix will at least prevent im_chat from crashing in enterprise edition.