This is where you are confusing me. In an earlier post you said that you were ativating the OUTPUT2 task from a LIST2 task (where the $inner entity contains rdcaccount_id), but now you are saying that this problem occurs when you are activating it from a LIST1 task (where the $main entity does NOT contain rdcaccount_id). This also means that you are using a navigation button in a parent task which works on a different table than the one in the child task, which in this case also means that the foreign key which is passed from the parent to the child is incomplete as it is missing rdcaccount_id.
I have played around with my code and have managed to get it to produce a WHERE string in the format:
(( cost_group_id='SDA2' ) OR (cost_group_id='SDA3' )) AND rdcaccount_id IN ('1', '7')
Try the attached file and see if it solves your problem.