Scenario: There is a project your boss is wholly responsible for. You, from a technical perspective, are absolutely indispensable to the success of said project. Maybe it's a small team, or everyone is overloaded, but you can draw a direct line between you quitting (or doing a bad job) and your boss getting called out or potentially fired.
Your boss, however, is not indispensable to their boss, nor is this project indispensable to the larger department. You ask for your raise because of your leverage. Your boss might be worried and try to get it for you. Their boss, not caring about this project that much in the broader context of their work, laughs and says no.
You can absolutely be critical to the success of a project, and even important to your boss's future, but have no real leverage over your situation. That's absolutely a reason to leave but it doesn't mean you'll be able to squeeze any more money out of the place before you do.
Such a great point to make. Specially since I see myself in similar situation. Maintaining a legacy system on which all the devs except me who worked in past have left. It is critical system or so I heard but as far as promotion/raise go, almost nothing for last 3 years.
However instead of getting angry I get that I may be important to direct boss or one level above. But as far as company goes they are all in cloud, next generation and what not. So my criticality is inconsequential in larger context.
That argument does not solve the problem. You will stay or go from one project that fails to the next like that. Better to have worked on projects that are still good on your CV.