Sara
I think I've seen you posting somewhere else and if I'm right please ignore the things that you're being told there right now. The poster there is not 'official' and has their own background and history.
Due to an abusive marriage I went through child protection planning when I had two young children and was pregnant with another. Had social services been looking for easy kids to adopt my youngest and the new baby would have been easy to place but at no point was that even raised, even when I asked them if doing that would protect the children from their father better than I could and offered them up if they could.
You've made great progress but the timeline is short for showing sustained change. I know this is going to sound horrible but right now I would suggest you 'forget' about fighting for your older child back and instead that you work with all social workers to support his placement and to show that your focus is on doing right this time with the new baby.
Go to your contacts and tell your older child how much you love him, tell him you're proud of him for being good where he is living and for working hard at school. Tell him how much you look forward to seeing him and hearing about all the nice things he's done with his carers, at school, with his friends etc. (It'll hurt to say it I know but pull your game face on and focus on the future.) tell him you love seeing him but don't tell him you miss him and when he says he misses you give him a hug and tell him you love him very much and that he doesn't need to miss you because you'll see him again soon.
Show his social worker that you accept that right now he's in the best place and that you want to support him the best you can to settle. If you can do this then you can ask for more contact because it won't be destabilising for him and you have your foot in the door. Step by step is the way to get him back but right now you need to focus on keeping the baby and showing you can keep it safe.
Stop contact with your ex, maintain your improvements and stick with it every day. Things might be tough right now but the future is still ahead and you can get where you want to be if you keep your focus and avoid being drawn in to arguing and fighting with the system.
Have they talked about a mother and baby placement? Maybe that's what they're looking for with the talk of court?
Good luck, I know it's not easy.