The word "they" could refer to "him" or "her". You could refer to "what he or she writes", "what he or she wants", or wants", or "the help that he and/or she needs".
Eventually some people tried to shorten "he and/or she" to "they".
Note: In JoeTaxpayer's answer, the same phrase could have been, "Whoever left his jacket in the library..." (instead of "their jacket").
Even for people who don't like "he and/or she" being replaced with "they", enough people have talked (and written) this way that most people will understand it easily. JoeTaxpayer's sample is a great example of how something can be wrong (really, "his jacket" would have been a better way of saying it), but sounds tolerable enough that many people may not even notice the issue.
Some people liked that. Some people didn't. The shortened version was liked by some people, and disliked by others. I believe the fair consensus is that this has is considered to be controversial. In other words, there is a lot of disagreement.
So, if anybody tells you that this is definitely "good English" that is widely accepted by most speakers, that is wrong. However, if anybody tells you that this is definitely "bad English" that is widely rejected by most speakers, that is also wrong. This "rule" of English is currently in a state of being questionable.
If you are thinking of using such a phrase yourself, the safest approach would be to think of another way of phrasing things, thereby avoiding the argument altogether.