But in many cases compassion may mean self sacrifice: time, money, effort etc. It's fine to expect something back, at least not being mean or more demanding to you or sour about why you didn't do more. There are toxic people like that that you better not help. You can learn it the hard way. Maybe it can be communicated better, but in many cases people are predisposed to see you as a threat. If you offer to help, they think you do it as a scheme to help yourself and screw them. And they will fume even years afterwards that you somehow screwed them over when you genuinely helped them. That you didn't help enough, that you were selfish etc.
You need to choose who you spend your finite energy on. Not every person in a bad place is some idealized angel who is thirsty for your help and will be grateful.
I'm more talking about when someone goes in the other direction and is notably unkind, inconsiderate, cold, exploitative, or otherwise disrespectful to you. That's when it's time to switch to a new strategy.
To me, ignoring a neighbor who greets you is pretty cold and disrespectful, but yeah, everyone has a different line when it comes to these things, and it depends a lot on context.
I found it only feels wrong because I expected something. So the problem is as much in my expectation as their behavior and based in a faulty assumption that interactions are a zero sum game. I don’t always embody non-transactional compassionate behavior but having tried both approaches, once you can get past the expectations of what people can do for you, I find it a better way to live.