iPhone X sometimes shows 0% battery & restarts over and over
Hi all, I just got my iPhone X replaced 2 months ago (so it's a very relatively new phone in my opinion.) Recently, I have been having issues where the phone continuously restarts and shows 0% battery over and over again. If I go into settings -> battery it will show 0% charge, and says that it cannot display battery health. But if I leave it be for several hours without doing anything, it will sometimes charge again and my phone will work again with regular speeds. I have tried third party apps such as Coconut Battery to evaluate my battery health, and it shows that it is operating at 96% of design capacity. I can never predict when my phone will go into this constant state of restarting with 0% battery. Does anybody have a possible solution to this or know how to fix it? I have tried factory resetting it, and I have tried factory restarting and loading it like a brand new phone (not loading a backup). None of these seem to help. Thank you!
iPhone X, 14