For background, my job requires me to make up large amounts of mock data. Large like 100s of thousands of rows, and array formulas seem to be the best option to scale these activities. Onto the problem.
I have 2 arrays

The first is a list of Accounts in one column and the Rep that owns the account in another. My second array is just random array of Reps. In the second array I want to choose one of the accounts that each rep owns - based on the assignments in the first array. These arrays are different sizes with the second being much larger given its just a random selection of reps with every rep being repeated multiple times.
All of the columns in both arrays are generated from other dynamic array functions using the # to reference and build the arrays.
This is the formula I originally came up with. In essence i'm trying to produce a filtered array of accounts that the lookup rep owns and then pick a random account from that filtered array.
=LET(
acctlist,$L$2#,
ownerlist,$M$2#,
replookuparray,Q2#,
filterbyowner,FILTER(acctlist,ownerlist=replookuparray),
INDEX(filterbyowner,RANDBETWEEN(1,ROWS(filterbyowner))))
I get a value error from this formula. If I remove the # from Q2# in the replookuparray it produces a correct result, but I want it to produce a result for the entire array 2 so I don't have to copy paste across the entire range (the numbers producing all of these arrays are volatile so they often change, and have one non-dynamic array makes the file much less useful).
Is there any way to get this logic to apply to the second array so I can maintain the use of dynamic arrays?