Many workers suffer from some form of mental illness, including things like depression and anxiety. Even if a mental health disorder makes it more difficult to do your job, your employer is not allowed to fire for this reason alone. The U.S. Equal Employment Commission explains how mental disorders must be treated in the place of work to ensure employers are compliant with prevailing regulations.
When encountering difficulties related to your mental health condition as it relates to work, you're allowed to request a reasonable accommodation from your employer. This means that the workplace will be altered in some way that makes it possible for you to fulfill your job duties. Accommodations usually depend on the person in question and what type of mental health issue he or she is experiencing. For example, some people might need directives to be communicated in a specific way. Others might feel uncomfortable in loud, noisy environments, so they might request a quiet workspace away from other employees.
In this case, it's up to the worker to request these accommodations. From here, the employer must make a reasonable attempt to see it comes to fruition. You'll probably be asked to put your request in writing, with backing documentation from a counselor or other mental health professional. While you're permitted to keep any medical conditions you experience private, in this scenario, you'll likely need to disclose at least some information to ensure your request is honored.
Despite any reasonable accommodations, you might still be unable to perform job functions. If so, ask your employer to be reassigned to a position you are capable of filling. If no such position exists, you may need to take leave of your employment. Some employers offer paid leave, which would allow you to earn an income while seeking assistance. You may also be eligible for unpaid leave according to FMLA regulations. In this case, your position would be retained while you seek assistance for mental health issues.