Mary thinks we can help her when she has а problem.
или
When Mary has а problem she thinks we can help her.
Mary thinks we can help her when she has а problem.
или
When Mary has а problem she thinks we can help her.