Barking up the wrong tree
Making a mistake or a false assumption in something you are trying to achieve.
The allusion is to hunting dogs barking at the bottom of trees where they mistakenly think their quarry is hiding.
The earliest known printed citation is in James Kirke Paulding's Westward Ho!, 1832:
"Here he made a note in his book, and I begun to smoke him for one of those fellows that drive a sort of a trade of making books about old Kentuck and the western country: so I thought I'd set him barking up the wrong tree a little, and I told him some stories that were enough to set the Mississippi a-fire; but he put them all down in his book."
The phrase must have caught on in the USA quickly after Hall's book. It appeared in several American newspapers throughout the 1830s; for example, this piece from the Gettysburg newspaper The Adams Sentinel, March 1834:
"Gineral you are barkin' up the wrong tree this time, for I jest see that rackoon jump to the next tree, and afore this he is a mile off in the woods.
See other phrases that were coined in the USA.