Comparisons between lists rg

Goodmorning everyone . I am trying to do something that is blowing my head. I am attaching some images to be clearer

I have these 2 rg nested. Now the numbers you see under each rg1 represent all the ids present within each rg2. Now every time the + key is pressed, I type in my order items table, entering it the id of that cell like this

Now what I need to be able to do is:
check if this order items contains a number equal to the max choice number of that specific group, then the button must be disabled. Example

Now I have already tried with a custom state, put inside rg2 which makes me +1 every time one adds an element of that list. The problem is that if it then goes to another product, the state does not reset and therefore inherits the values ​​it had during the first choice, plus playing with the state, I have no way of saying which elements are already present (in case of edit), while if you could compare lists then it would definitely be the best choice.

The condition should be something like this

"Do search for Order Items variants_list contains a number of items (which are within this group)> = of current cell choice_max then the button must be disabled

But I have not been able to impose this condition
Thanks in advance if anyone will be able to help me

I found the solution

I share that if it can be useful to someone

This topic was automatically closed after 70 days. New replies are no longer allowed.