You just have to remember one rule: If the direct object comes before the verb, the 'participe passé' has to be in agreement with the direct object. For example,
"J'ai vu une femme." This means you saw a woman, woman being the direct object and coming after the verb 'voir'. But if you put 'woman' before the verb, like in this sentence,
"La femme que j'ai vue était la nouvelle copine d'un de mes amis."
The participe passé of 'voir' has to go with the direct object, 'la femme.'
Other examples:
"Je les ai vus à l'école." I saw them at school, but in french, the 'them' comes before the verb 'voir' so the participe passé of 'voir' has to go with the direct object.
But if you saw "J'ai vu Jean et Marc à l'école," the direct object 'Jean et Marc' comes after the verb so there's no modifying the participe passé.
(and if you saw two women, it'd be "Je les ai vues...")