Make many-to-many grid invisible in detail view from lookup view

Hello

I have two entities ProductCategory and Product in M-M relationship. Now my requirement is that user can go to ProductCategory view, click Add to open Product lookup and, if needed, can add Product from there but ProductCategory grid is visible in Product detail view. Same is the case with adding ProductCategory from Product detail view.

Is there a straight forward way to make ProductCategory/Product grids invisible when creating entity from list view opened as lookup without passing around variables?