你的句子是动词不定式作定语.share的结构是:share---withsb.
你的句子可以改写成以下句子,请仔细阅读,然后你就明白了:
1shewantedtofindafriendtoshareherhappinessandsorrowwith.
2shewantedtofindafriend.Shecouldshareherhappinessandsorrowwiththefriend.
3shewantedtofindafriendwithwhomshecouldshareherhappinessandsorrow
4shewantedtofindafriend(that)shecouldshareherhappinessandsorrowwith.