It is not illegal to add people to WeChat. No matter whether you leave a number or do something, it is illegal only if you do something illegal.
Breaking the law is also called "invalid behavior". An illegal act. Acts that violate the law. Different from the objective illegal behavior, the actor is subjectively at fault when carrying out the behavior, thus infringing on the social relations protected by law.