Accessing components inside of containers in a list view from a script

If I have a List View with an array of collapsible containers that all have a few items in them, how can I access the values in each of these items?

For example, I have this ListView called searchByMerchantContainer that contains n collapsible containers called searchByMerchantcollapsibleContainer. Within these collapsible containers, I have fields populated by a graphql query - searchByMerchantProductId and searchByMerchantNameOverrideBrand.

I want to be able to iterate through all of these items when I click a save button and call an update graphql mutation for each id. I have this code written on the save button click: => updateProductBrandByCuid.trigger({
additionalScope: {
editProductId: item.searchByMerchantCollapsibleContainer.searchByMerchantProductId,
brand: item.searchByMerchantCollapsibleContainer.searchByMerchantNameOverrideBrand

I believe I am adding the scope correctly to the graphql mutation; however, when I try to run this save function from the retool app, I get the error:

Error:Cannot read properties of undefined (reading 'searchByMerchantProductId')

I've also tried item.searchByMerchantCollapsibleContainer.body.searchByMerchantProductId to no avail. It seems like the script cannot access anything below the level of searchByMerchantCollapsibleContainer in the foreach loop. Am I missing something here?