Cannot change content source in host group

Problem:
A remote smart proxy has a cert problem and Foreman cannot communicate with it. I want to remove the smart proxy but it is referenced in several host groups. When I try to reset the content source in an affected host group, it fails and production logs show the error “Failed to save: Base The selected content source and lifecycle environment do not match”. Everything is set to Production.
This problem has also prevented upgrading which is now critical.
Expected outcome:
Reset content source successful in host groups.
Foreman and Proxy versions:
Foreman 2.3.5
Katello 3.18.5

Foreman and Proxy plugin versions:
All packages latest for 2.3 and 3.18

Distribution and version:
CentOS 7.9

Other relevant data:

2022-01-28T09:43:35 [I|app|21979a6e]   Parameters: {"utf8"=>"✓", "authenticity_token"=>"IB6m0eJ5m5teloBxymH44bR5fy+1qC8k+p+/T2MpZUqRF1UOQsLQxo7+sOOIus54NmeBT+AnvWggkopsInt8kg==", "hostgroup"=>{"parent_id"=>"", "name"=>"RHEL 7", "description"=>"", "lifecycle_environment_id"=>"5", "content_view_id"=>"50", "content_source_id"=>"1", "environment_id"=>"1", "compute_resource_id"=>"", "puppet_proxy_id"=>"1", "puppet_ca_proxy_id"=>"1", "openscap_proxy_id"=>"1", "ansible_role_ids"=>[""], "puppetclass_ids"=>[""], "domain_id"=>"1", "subnet_id"=>"1", "realm_id"=>"", "architecture_id"=>"1", "operatingsystem_id"=>"", "medium_id"=>"", "ptable_id"=>"", "group_parameters_attributes"=>{"0"=>{"name"=>"kt_activation_keys", "parameter_type"=>"string", "value"=>"[FILTERED]", "hidden_value"=>"[FILTERED]", "_destroy"=>"0", "id"=>"180"}}, "location_ids"=>["6", ""], "organization_ids"=>["3", ""], "id"=>"18"}, "commit"=>"Submit", "id"=>"18-RHEL 7"}
2022-01-28T09:43:35 [E|app|21979a6e] Failed to save: Base The selected content source and lifecycle environment do not match

For clarification: The host groups in question (there are three) are currently set to the remote smart proxy as content source. I need to set them to the Foreman server. Attempting is what produces the error.

This is resolved. Moving all hosts out of associated host groups and deleting the host groups allowed the smart proxy to be removed.