Drupal - Disabling module with config sync and removing with composer

You need two consecutive releases for stuff like that.

First release:

Your colleague uninstalls the module and commits the updated config.

If you don't manage your site via config use hook_update_N instead.

/**
 * Uninstall SOME_MODULE module.
 */
function MYMODULE_update_8001(&$sandbox) {

  \Drupal::service('module_installer')->uninstall(['SOME_MODULE']);
}

Second release:

The module can be removed via Composer.


Related:

Order of drush commands for automated deployment?


Adding an alternative solution to @leymannx - you will still need two releases. This is taking into consideration your mention of drush cim

First release:

  1. Uninstall the module drush pmu module_name
  2. Export the configuration.
  3. Commit, push, and release.
  4. Deploy and execute drush cim. That should uninstall the module.

A hacky way to uninstall is directly editing the core.extension.yml, remove the complete entry of the module from under the module: key, and executing drush cim. NOTE: Use this hacky way only when you are sure that the module doesn't export any configuration. Else, there would be an exception thrown.

Second release:

Removing module from composer.