If they stay, most likely wasted. Or they succeed despite the organization, but ultimately fight an uphill battle the entire time. It's usually best to just leave, but that also creates a vacuum that will be filled with an incompetent (or subpar) yes-man further exacerbating the problem.
That can create conflict for civil service employees. To stay where you're not that useful and feel it's a waste, but you're doing some good by shouting into the storm and trying to hold back the stupidity. Or to leave and let an incompetent person take over behind you (or competent but overworked because they don't fill the position). If you stay in that situation it's out of a sense of duty, but it's incredibly exhausting.
In case where corruption and nepotism are wide spread in a society, only thing competent people can do is leave the society or country.
In my opinion, nepotism is bigger problem than corruption in the middle east. A lot of these corrupt deals happen through family connections. And then you go to private industry, and you will find that all the higher up people are usually related to each other.
So most of the ambitious people leave for the west causing further damage to society with brain drain.
Competence is as much state as fitness is, i.e. people loose it if their job does not allow them to be competent and they are unable to switch.
I have seen really competent people become incompetent overtime in soul crushing paper pushing jobs. You work long enough in a such job, you become the exact kind of person you despised when you started.
It is especially acute in governmental jobs which have lesser scope for role changes etc.
Sometimes they end up in the private sector, where small enough firms can avoid the corruption that gets into larger bureaucracies. Often they end up leaving the field or the country - there are lots of great Lebanese engineers outside of Lebanon.