Filter to sum on gridView

I'm working in a Retool cloud app where on a gridView coponent I’m trying to calculate the sum of a field called budget_ammount from budgetRetriever.data query from Retool DB and show it into a Statistic component within the gridVew, filtered by three conditions: the budget_concept_name must match the current item.name, and the budget_date must fall within the selected month and year (month5.value and year5.value). I'm using _.filter and _.sumBy, handling cases where month5 and year5 might be arrays, and also ensuring that budget_ammount is converted to a number with a fallback to 0. However, the result is always 0, and I suspect one of the values involved in the filtering might be undefined or null. I've already verified that the input values exist and look correct, and I've used console logs in transformers to debug, but still no luck. Any ideas on what could be going wrong?

{{ 
  _.sumBy(
    _.filter(budgetRetriever.data, chain => {
      const conceptMatch = chain.budget_concept_name === item.name;
      const month = Array.isArray(month5.value) ? Number(month5.value[0]) : Number(month5.value);
      const year = Array.isArray(year5.value) ? Number(year5.value[0]) : Number(year5.value);
      const date = new Date(chain.budget_date);
      const monthMatch = date.getMonth() + 1 === month;
      const yearMatch = date.getFullYear() === year;
      return conceptMatch && monthMatch && yearMatch;
    }),
    chain => Number(chain.budget_ammount) || 0
  )
}}