I am not sure why that’s not working, at first glance it appears okay, but…
That you can’t do. Cascading prompts, as they are called, can only go through a linear path. So you can prompt for state and then based on that select a city. But you can’t really prompt for state and based on the results prompt for city for some states, and county for other states, because it is not a linear path.
Ultimately you have to compare to something with a prompt as well. An object with @Prompt() and nothing else is not going to work as a condition, only as a result object.
What you can do is to change the logic of the prompts for example in this way:
Have 2 prompts - one will be asking for invoice number(s) and one for date range. Set both prompts so they will allow users to select ALL for all values (look here and here to see how to do it).
If the users use ALL in date-range prompt and some invoice number(s) in the 2nd prompt it will be logically same as your ‘I’ (search by invoice) and invoice number.
And if users use ALL in invoice prompt and some value(s) in date-range prompt it will be the same as your ‘D’ (search by date) and date.
And you will need to explain to users how to use these 2 prompts.