Child Behavior: Frequently Visiting the Bathroom to Avoid Situations
If it turns out the behavior is not compulsive, you may be able to help your child overcome this behavior using a reward system. Have your son go to the bathroom before meals and set a goal of his sitting through the entire meal without going to the bathroom. At the end of the meal, give him a small or immediate reward for making it through—like dessert or an extra 15 minutes of playtime—or by making a "star chart" where he earns a star for reaching the goal and then accumulates stars to earn larger prizes.
If this goal is too hard for him, set an easier goal of making it through the first 15 minutes of the meal and work your way up to the entire meal. Once you conquer mealtime, expand the system to other times he goes to the bathroom to avoid something he does not want to do.