Modify the visibility of collections locally to the viewport with python
We have been reviewing it and we have realized that the problem was in the context overwrite. Although we have already done this, we did it by selecting the wrong area

ctx_override = context.copy()
ctx_override['area'] = get_area(context, 'VIEW_3D')


The function get_area (…) returned the area of ​​the viewport in which to make the changes, but did not select the correct viewport, since having two in the interface always takes the first one located in the vector, which was a viewport with local visibility of collections deactivated.

Now we differentiate the viewports by their width to make the changes in the correct viewport