Unable to change puppet Environment for Custom Role

Problem:
I have created a custom role for allowing restricted host administration. The role has a filter for edit_hosts permission with a custom search which is preventing the user from moving the server to different puppet environments.

Expected outcome:
The user should be able to edit the host that matches the search criteria on the Role filter.

Foreman and Proxy versions:
foreman = 1.19.1
foreman_proxy = 1.19.1

Foreman and Proxy plugin versions:
foreman_memcache = 0.1.1
puppetdb_foreman = 4.0.0

Other relevant data:

{"logger":"audit","timestamp":"2019-04-11T16:44:04.269368-05:00","level":"INFO","message":"update event for Host::Base with id 1243","mdc":{"remote_ip":"x.x.x.x","request":"766f8942-a1c3-4195-9dff-25725a330812","session":"990aaa57-fd69-4b82-a3ae-f37ac384b86a","user_login":"jguevara","user_admin":false},"ndc":[{"environment_id":[29,345]}]}
{"logger":"app","timestamp":"2019-04-11T16:44:04.864783-05:00","level":"ERROR","message":"Failed to save: You don't have permission edit_hosts with attributes that you have specified or you don't have access to specified locations or organizations","mdc":{"remote_ip":"x.x.x.x","request":"766f8942-a1c3-4195-9dff-25725a330812","session":"990aaa57-fd69-4b82-a3ae-f37ac384b86a","user_login":"jguevara","user_admin":false},"ndc":[]}

I think I found the reason. Apparently foreman somehow checks that after editing your role filter for edit_hosts still returns true. I changed my filter to include the target environment I was moving my host to, and it worked. So for my case I changed the filter.