Hi Guys,
I had a similar issue with my iPhone X, but I followed my suspects and I solved the problem.
In my case, I had a replacement of the original battery during the Apple replacement battery program at the end of 2018 in an Apple Premium Reseller and after that my problems started (unexpected restarts, after restarts, battery which was shown 0% and after few seconds was back to normal charging percentage etc).
Since then, I had the suspect that something went wrong with the replacement. Therefore I decided to go for a new replacement in an official Apple Store and I have solved all my issues.
The iPhone didn’t restart anymore and it’s again reliable.
I hope this can help, I know the frustration you can feel.