Kant says that someone who does something motivated by sympathy to help someone would not be doing something of true moral worth. Doing something with the end goal of helping someone else would seem morally correct, but it’s a hypothetical imperative. A hypothetical imperative is when an action is commanded for bringing about some further end, or an imperative based on inclination or desire. Things that are truly morally correct would be a categorical imperative as those are actions that are commanded for being good without qualification, which shows good will — things that are good in themselves. Acting out of obligation to someone else is not acting truthfully or morally as there is reason behind the actions being made.
The way I see it, doing something of true moral worth is doing something without question, obligation, or reciprocation. If I were to see a homeless person and desire to give them food because I felt bad for them or because I wanted others to think I was charitable, instead of doing it out of the goodness of my heart, then it is not a moral act.