I think that suicide could have some evolutionary advantage in a group. Say there is a member of a group who has become sick, injured, or otherwise incapacitated and is unable to contribute to the group. The group must spend more work to take care of the member than they receive back from the individuals paltry, or nonexistent contributions to the group. If the member's ailment is temporary, then it would be advantageous for the group to bear the burden of taking care of the member, as they would benefit more in the long run.
However, if the member's condition is more permanent, then they represent a net loss to the group's well-being. It would then benefit the group as a whole if that member were to commit suicide, eliminating their burden from the group.
I think this is something that many individuals with suicidal ideation feel on some level. They think that they cannot contribute to their group (family, friends, job, community, country, etc), and that their lack of contribution will be indefinite. For example, a person with anxiety so bad that they are unable to leave the house or get a job might feel like a burden to their family, and unable to contribute. Or, a person with depression might have such a low opinion of themselves that they are unable to see the contributions they are making, or think that their contributions are meaningless and so feel like they are not contributing anything at all worthwhile.
Even though suicide could have had evolutionary advantages in the earlier days of human existence, in modern times I don't think this is the case any longer. With modern medicines and technologies, medical conditions are not as crippling as in the past, and there are more ways to contribute to a group than ever, even without being able to walk or leave the home. The difficulty would then seem to be either helping the suicidal individual to find a group and method of worthwhile contribution, or helping the individual to understand the ways they are already contributing to a group and why that contribution is worthwhile.
Of course, this is just a baseless theory of mine, and I would be very curious to see if there is any actual evidence to back this up.