As much as I sympathise with how unsettling and distressing this must be for you, gently OP you need to give your head a firm shake, get out of bed and get cracking! It’s time for you to start thinking practically as to how you can go into the court hearing in the best state possible and what you need to do to make that the case.
This link walks you through the court process step by step:
https://helpwithchildarrangements.service.justice.gov.uk/going-to-court-other-parent
Read it, familiarise yourself with what you need to do and what the process looks like so there are no surprises and then preemptively prepare yourself for what may come and any emotional response that may come with it, so you can be ahead of your feelings and hopefully better navigate them.
The below link is from the gov.uk website itself with advice on options available to get emotional support:
https://helpwithchildarrangements.service.justice.gov.uk/emotional-support
Do consider if any of these resources could be helpful to you as you go through the court process. If so, make sure you use them.
You should also reach out to CAFCASS and maybe look at the Both Parents Matter website as they have lots of fact sheets with information, as well as support groups etc that may be helpful:
https://bothparentsmatter.org.uk
If you have any family or friends who can help you with form filling, gathering evidence and supporting materials or even to just be there as a sounding board and a shoulder to cry on if needed, reach out to them. Ask for their help. Don’t try to muddle through this alone if you have people around you who can help.
I would also start reaching out to anyone who knows you, your child and has any potentially valuable insight they can share as to your parenting approach over recent years: teachers, social workers (if any are involved), your GP/mental health team, any close co-workers/manager etc. Basically, anyone who can vouch for your improved mental health in the last 2 years and/or can attest to the high and consistent level of care, love and support you have provided for your child during that time.
Don’t let the fear paralyse you, as I worry that would just play into your Ex’s hands and reinforce his argument. Instead, find your anger. How dare he torpedo the success you’ve made of your life over the last 2 years? How dare he question and undermine the quality of care and parenting you provide your child, when he’s been prepared for you to be responsible for looking after your shared child 50% of the time thus far? How dare he try to continue the pattern of abuse and manipulation he used during your relationship now after you’ve separated, trying to label you unfit, destroy your confidence and trigger a relapse in your mental health journey?
Do not let him win. If not for you, then for your child.