I think it always does, as long as the noun makes sense. Like, it has to match for gender, plural-ness, or whatever, but otherwise... that's the rule. Pronoun refers back to the last noun that makes sense.
"Andrea bought Sally a book. She loved to read, especially memoir and women's fiction. Finding her a gift was never a problem. She would sit for hours in the Starbucks with her latest book, sipping coffee and reading." In the bolded part, are any of the pronouns unclear to you? Can you tell if they refer to either Andrea or Sally, or both depending? Answer as I understand it: Spoiler They all belong to Sally.
This is perfectly clear to me. The "finding her a gift was never a problem" reinforces the idea that all this is about Sally since she was the recipient of the book mentioned prior; thus, this refers to said book, a perfect gift for Sally, bought by Andrea, for all the other reasons mentioned.