TO BE BARKING UP THE WRONG TREE (informal)
= to be wrong about the reason for something or the way to achieve something