With the subject: The past participle only agrees with the subject of the sentence when the auxiliary (auxiliaire in French) is the verb ‘être’. When the auxiliary ‘avoir’ is used, the past participle never agrees with the subject.
Example: Elles sont allées a la plage. Elles se sont baignées. Elles ont mangé des glaces au chocolat.
With the direct object: The past participle agrees with the direct object or direct object pronoun when they are located before the auxiliary ‘avoir’.
Example:
Les glaces au chocolat que vous avez mangées etaient bonnes? Direct object: 'les glaces au chocolat', located before 'avez'.
Nous les avons mangées. Direct object pronoun: 'les' which refers to 'les glaces au chocolat', located before 'avons'.