Answer: its function in the sentence.
Explanation:
There´s a grammatical rule to determine the function of a pronoun in a sentence when used as part of a compound. Which pronoun to use will be established by its function in the sentence.
For example, in the Subject position, "he," "she," or "I" should be used. However, as the Object of a verb or preposition, "I" is replaced by "me," "he" is replaced by "him," and "she" is replaced by "her."