I don't know, I feel like if they wanted to destroy Barba's character (or wanted to be successful in doing so) then they would've had him continue to be Wheatley's lawyer once the trial was over.
I think Barba's reasonings for taking the case were sound and did fit in with this character (to some degree). Naturally there were bits that felt OOC but not enough to be alarming. And like, he and Liv (and others) will definitely end up on good terms again (although I don't always trust the writers and suspect they'll have them reconcile only when absolutely necessarily).
Not to mention, there was such a good job done of Barba's expressions/reactions throughout. You could see him being apprehensive about Wheatley even though he thought the case was worth working on. And his expression when Liv said she felt betrayed showed how much that affected him. There were other little moments too. He wasn't heartless or taking the case to spite his friends or anything. And again, I think him turning down Wheatley once the trial was over shows it really was about that specific case (and the details of it in terms of police work and evidence) and not because it was Wheatley.
Barba thought going into it was that there was room for reasonable doubt and that the evidence was sketchy (as well as the procedures taken, like having Elliot involved from the start). We as an audience know that Wheatley is involved in some way and that he's a horrible, dangerous man but people like Barba can't be sure if he's to blame for the crime at hand (Kathy's murder) when the evidence and whatnot is shaky (especially from an outside perspective). And hell, maybe he wasn't involved. Based on the OC 2x09 ending, maybe it was all Angela. (Although I doubt he wasn't involved at least to some degree).
I think Barba being brought in for the reasons he was actually sheds light on how the investigation was handled at times and highlights how good Wheatley (and/or his family) are good at covering their tracks and/or deflecting attention away from themselves. I think the balance between helping the plot and keeping Barba in character could've been a bit better but it was still there. And it was perfectly clear it was the case and how it was handled that attracted Barba to become involved and not the fact that it was against his friends (/loved ones) and certainly not because of Wheatley.
Honestly, for me at least, the major downside is that it'll probably be a while before he appears again (or is mentioned as having appeared in canon but off camera) and he and Liv (and whoever else) catch up again. I do also think there could have been more time dedicated to Liv and Barba actually talking post trial to discuss in more detail why he took the case to really solidify it was about upholding the law and making law enforcement responsible for how they tackle cases so that no one, but particularly someone with less power than Wheatley, doesn't get trapped in the system but alas.
Either way, Barba, my love, I hope the writers bring you back again soon 💙