From MoodleDocs

The ID for the course module is invalid. Please contact the site admin.

For some unknown reason, this happens sometimes when deleting a user. Clicking the back button of the browser and deleting the user again, makes the deleting process continue and delete the user.

It can also happen when "Legacy course files" is enabled. Disabling this can solve the issue.