Either way I'm a useless person. I don't serve a purpose at all. I'm a failed outcast of society because I don't contribute in some way.
There is a name for this : it is called "performance society". In the social model we all live in, our value is linked to our performances, in every field. We value if we are good students, if we are good workers, we we have good mental health, if we succeed, if we correcly carry our own lives, if we meditate well if we behave well, if we are good at something, and so on. In every way, in every moment, we have to perform - well. So the revers : if ww do not perform, we do not have any value. If something slips out of our control than it must be put in place, in order for us to keep on performing. Toxic positivity is a part of that : there is no space to feel bad, you always have to be positive (performing, again).
There are tons of philosophical studies about that.
This is exactly what you are saying : I serve no purpose = useless person.
I know it is a bit of an abstract answer, but I hope you get the point of this, which is exhistential : this is something we are **taken to think** by the way society is built at the moment. This is not any kind of truth.
What I am trying to say is that when this thought come over try to speak to it, replying "ok, I hear you, but you are not telling the truth. You telling a lie, and while I cannot make you shout your mouth up, I can choose not to listen to you".
I hope this helps somehow, at least to make you feel a little better about yourself.