I did the factory reset the phone but it did not help.
I came across the below thread on Reddit and it worked for me. I had to update/replace the firmware of the phone to firmware made for Xfinity Mobile.
Firmware installation is pretty easy on Samsung phones, only you need Odin Windows Software and Firmware file. Connect the phone and install the firmware. You can find tutorials on Google/Youtube.
I downloaded Xfinity firmware from https://www.sammobile.com/
Please check for "Comcast (CCT) " while downloading any firmware that is for Xfinity Mobile.
This way I think you can use any Galaxy S8 and above phones with Xfinity Mobile even IMEI says it is incompatible. Only you need is SIM from Xfinity mobile and phone updated with the latest Xfinity mobile firmware.