2 Year Old Constipation, HELP!

Ni
My nephew has always had pooping problems. He always has trouble and he was up past 12 am last night crying and screaming because his bowel movements hurt him so bad. My brother (his dad) has given him prescription baby miralax until we found out it causes some brain issues and now he gives him another supplement. He also drinks pear and prune juice watered down to help him but his poops literally look like round balls so I imagine the pain he's in for being only 2 years old. Is there any other ways to help him go less painfully?