Upon defeating a Barbarian unit inside an encampment, there is a 50% chance you earn 25 gold and they join your side.
The barbarian unit is the topic of the sentence, so "they join your side" (meaning the people that the unit represents) means the unit joins your side. The encampment is where the unit (the topic of the sentence) happens to be (a detail about the topic of the sentence).
There is no reason to think that the word "they" would imply "encampment" more than "unit", since both are singular, so we can assume it's just an accidental change in tense that still applies to the topic of the sentence like it would if "they" was correctly written as "it".
If the encampment was to join your side, the sentence would begin "Upon capturing a barbarian encampment with a unit in it..."