Being extremely depressed actually reduces short term risks of suicide because planning shuts down. It's the middle ground where things are bad, but people can still think that has the highest risks.*
*Excluding hospital assisted suicide where someone OD's on pain medication under end of life pain.
But "no hope" is not equivalent to "extremely depressed".
Think of people who commit suicide over inescapable scandals, chronic pain, or terminal illness. Extremely depressed comes with 'no hope', but that's cancelled out by 'decreased agency' (which is one theory for why antidepressants carry suicide risk). Not every form of hopelessness shares that loss of agency.
I think hope plays a big part. We don't kill ourselves because we have hope. If we are suffering and have no hope, that's a recipe for suicide.