As I’ve mentioned above, soaps and detergents are very different, so there isn’t a single, simple answer to this question.
Detergents, which feature an ingredient list based on man-made chemicals, can be quite harmful to the environment and the used water should be disposed of properly. Ideally, you would prevent used water with detergent foam from going down the drain, as it can cause significant damage to water bodies and aquatic life in your local rivers and lakes.
While on the other hand, soap is usually biodegradable, based on natural chemicals, which makes it much safer to use.
Because of this, you shouldn’t worry about the soapy water running down your drain. But there are some soaps which are more eco-friendly than others, so you should always look for products that clearly state that they are eco-friendly.