It could be simplified down so easily. The only reason why having a mental illness should/could matter is because said person may be unable to do the job to the required standards. So why not just look at the last reason? Mental illnesses don't even need to be involved. The only question should be "are they cabable of doing the job?". Sure, a person's mental illness might prevent them from doing the job, but that's not to say everyone with that mental illness will also be unable to do the job.
Thinking of a relate-able example, preventing someone from being a doctor because they have X mental illness is like preventing someone boarding a plane because they are X religion.