You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$175] [Sentry: APP-P9K] TypeError: Cannot read property 'at' of undefined in hasEnabledListValue #107169
hasEnabledListValue iterates over reportField.values and unconditionally accesses reportField.disabledOptions.at(index). When values contains entries but disabledOptions is undefined, this throws during rendering.
The error indicates a missing array, not an unsupported .at() method. Field merging does not normalize this property. The exact origin of the affected field remains unconfirmed.
changed the title [-][Sentry: APP-P9K] TypeError: Cannot read property 'at' of undefined in hasEnabledListValue[/-][+][$175] [Sentry: APP-P9K] TypeError: Cannot read property 'at' of undefined in hasEnabledListValue[/+]on Nov 17, 2026
Confidence: medium. The code explains the reported exception, but production payloads and exact release-source mapping were not independently verified. Sentry/log access was unavailable; the origin of the missing array remains unknown. No runtime reproduction or tests were run.
An empty flags array is already safe. Missing values would instead fail at .some(), so that does not explain the supplied error.
What changes do you think we should make in order to solve the problem?
Use !disabledOptions?.at(index) when checking each value’s disabled flag. This preserves existing semantics: absent flags mean enabled; explicitly disabled values remain excluded.
Apply this consistently to the visibility helper, inline dropdown, dynamic editor, and initial-value picker so the fix does not simply move the crash downstream.
Extend existing visibility tests to cover missing, empty, shorter, mixed, and fully disabled flag arrays, plus empty values.
Extend report-field rendering tests to verify a field with omitted flags renders, opens, and accepts a selection. Helper tests alone would miss the second crash.
What alternative solutions did you explore? (Optional)
Hiding fields whenever flags are missing would prevent the exception but incorrectly hide enabled choices. Reusing old report flags while adopting policy values risks misaligning positional flags.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/107169) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
The report-field visibility check assumes disabledOptions always exists. When a list has values but no disabled-flags array, accessing .at(index) throws during rendering.
An editable dropdown repeats the same access, so fixing only the visibility check would move the crash downstream.
The code supports this mechanism; the production origin of the missing array remains unconfirmed.
What changes do you think we should make in order to solve the problem?
Use !reportField.disabledOptions?.at(index) in both checks. Continue iterating over values: missing flags should mean enabled, while explicit true flags should disable their corresponding options.
Apply the same guard to the other dropdown readers for consistent handling.
Extend visibility tests for missing, empty, shorter, mixed, and fully disabled arrays, plus empty values.
Extend rendering tests to verify a dropdown with omitted flags renders and accepts a selection. These are proposed tests, not executed results.
What alternative solutions did you explore? (Optional)
Hiding fields when flags are absent would avoid the exception but incorrectly hide enabled options.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/107169#issuecomment-6961572298) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
It's called from shouldHideSingleReportField, which MoneyRequestViewReportFields.tsx runs while rendering. The PolicyReportField type declares disabledOptions: boolean[] as required, but the data doesn't always include it. The comment right above the function already notes that fields created outside NewDot can come with an empty disabledOptions array. The crash shows they can also come with none at all.
Also, when merging report fields, getAvailableReportFields copies disabledOptions: policyReportField.disabledOptions onto the report's field. So an undefined value on the policy field overwrites whatever the report field had.
The same unguarded .disabledOptions.at(index) appears in two more places that would crash next, once the user opens that field:
What changes do you think we should make in order to solve the problem?
In hasEnabledListValue, use reportField.disabledOptions?.at(index), so a missing array means every value is enabled. That matches the behavior the existing comment describes for empty arrays.
Apply the same ?. guard in ReportFieldInlineInput.tsx and DynamicEditReportFieldPage.tsx.
Change disabledOptions to optional (disabledOptions?: boolean[]) on PolicyReportField in src/types/onyx/Policy.ts, and on the report field type in ReportNameValuePairs.ts. TypeScript will then flag any other unguarded access. The write paths in actions/Policy/ReportField.ts that call .push/.splice should default to [] first.
What specific scenarios should we cover in automated tests?
Unit tests for shouldHideSingleReportField / hasEnabledListValue with a list field where disabledOptions is:
undefined → not hidden, no throw
[] → not hidden
partially filled (e.g. [true] with 2 values) → not hidden
all true → hidden
Plus a render test that MoneyRequestViewReportFields doesn't throw for a list field without disabledOptions.
What alternative solutions did you explore?
Normalize the field once, in the report-field merge in getAvailableReportFields (disabledOptions: policyReportField.disabledOptions ?? field.disabledOptions ?? []). That covers the report view, but not fields read directly from the policy or from reportNameValuePairs, so I'd still add the guards above.
Web verification blocked by unavailable test data, not an observed App regression. The account has no reports, and supported tools cannot inject the required omitted-disabledOptions fixture.
Step
Status
Report renders with missing disabled flagsBlocked: account has no reports.
❌
Dropdown opens and accepts selectionNot exercised: required fixture unavailable.
❌
Disabled options remain excludedNot exercised in the browser.
Both targeted suites passed: 1,760 tests. Lint, typecheck, spelling, and Storybook smoke checks passed. Full-suite timeout and compiler/formatting-command limitations are documented in the PR.
Activity
expensify-chore-bot commentedon Nov 17, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @aimane-chnaif (
External)[-][Sentry: APP-P9K] TypeError: Cannot read property 'at' of undefined in hasEnabledListValue[/-][+][$175] [Sentry: APP-P9K] TypeError: Cannot read property 'at' of undefined in hasEnabledListValue[/+]expensify-chore-bot commentedon Nov 17, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022122803460444526222
mountiny commentedon Nov 17, 2026
@MelvinBot can you propose fix?
MelvinBot commentedon Nov 17, 2026
Proposal
What is the root cause of that problem?
A list report field with populated
valuesbut missingdisabledOptionscrashes the visibility check because it calls.at()on the missing array.A helper-only fix is insufficient: editable fields subsequently perform the same unsafe access while building their dropdown options.
Code evidence and confidence
disabledOptions.at(index).Confidence: medium. The code explains the reported exception, but production payloads and exact release-source mapping were not independently verified. Sentry/log access was unavailable; the origin of the missing array remains unknown. No runtime reproduction or tests were run.
An empty flags array is already safe. Missing
valueswould instead fail at.some(), so that does not explain the supplied error.What changes do you think we should make in order to solve the problem?
Use
!disabledOptions?.at(index)when checking each value’s disabled flag. This preserves existing semantics: absent flags mean enabled; explicitly disabled values remain excluded.Apply this consistently to the visibility helper, inline dropdown, dynamic editor, and initial-value picker so the fix does not simply move the crash downstream.
Additional locations and regression coverage
Additional unsafe readers:
Extend existing visibility tests to cover missing, empty, shorter, mixed, and fully disabled flag arrays, plus empty values.
Extend report-field rendering tests to verify a field with omitted flags renders, opens, and accepts a selection. Helper tests alone would miss the second crash.
What alternative solutions did you explore? (Optional)
Hiding fields whenever flags are missing would prevent the exception but incorrectly hide enabled choices. Reusing old report flags while adopting policy values risks misaligning positional flags.
Related issue: Disabled list field appears after deletion concerns the same visibility area but reports different behavior; it is not a confirmed duplicate.
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/107169)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run
MelvinBot commentedon Nov 17, 2026
Proposal
What is the root cause of that problem?
The report-field visibility check assumes
disabledOptionsalways exists. When a list has values but no disabled-flags array, accessing.at(index)throws during rendering.An editable dropdown repeats the same access, so fixing only the visibility check would move the crash downstream.
Supporting code
The code supports this mechanism; the production origin of the missing array remains unconfirmed.
What changes do you think we should make in order to solve the problem?
Use
!reportField.disabledOptions?.at(index)in both checks. Continue iterating overvalues: missing flags should mean enabled, while explicittrueflags should disable their corresponding options.Apply the same guard to the other dropdown readers for consistent handling.
Other readers and regression tests
Other readers:
Extend visibility tests for missing, empty, shorter, mixed, and fully disabled arrays, plus empty values.
Extend rendering tests to verify a dropdown with omitted flags renders and accepts a selection. These are proposed tests, not executed results.
What alternative solutions did you explore? (Optional)
Hiding fields when flags are absent would avoid the exception but incorrectly hide enabled options.
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/107169#issuecomment-6961572298)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run
fitzyracing1 commentedon Nov 17, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
Opening a money request report crashes with
TypeError: Cannot read property 'at' of undefinedinhasEnabledListValue(Sentry APP-P9K).What is the root cause of that problem?
hasEnabledListValueinsrc/libs/ReportUtils.tsassumesdisabledOptionsis always an array:It's called from
shouldHideSingleReportField, whichMoneyRequestViewReportFields.tsxruns while rendering. ThePolicyReportFieldtype declaresdisabledOptions: boolean[]as required, but the data doesn't always include it. The comment right above the function already notes that fields created outside NewDot can come with an emptydisabledOptionsarray. The crash shows they can also come with none at all.Also, when merging report fields,
getAvailableReportFieldscopiesdisabledOptions: policyReportField.disabledOptionsonto the report's field. So an undefined value on the policy field overwrites whatever the report field had.The same unguarded
.disabledOptions.at(index)appears in two more places that would crash next, once the user opens that field:src/components/MoneyRequestReportView/ReportFieldInlineInput.tsx(enabledOptionsfilter)src/pages/DynamicEditReportFieldPage.tsx(fieldOptionsfilter)What changes do you think we should make in order to solve the problem?
hasEnabledListValue, usereportField.disabledOptions?.at(index), so a missing array means every value is enabled. That matches the behavior the existing comment describes for empty arrays.?.guard inReportFieldInlineInput.tsxandDynamicEditReportFieldPage.tsx.disabledOptionsto optional (disabledOptions?: boolean[]) onPolicyReportFieldinsrc/types/onyx/Policy.ts, and on the report field type inReportNameValuePairs.ts. TypeScript will then flag any other unguarded access. The write paths inactions/Policy/ReportField.tsthat call.push/.spliceshould default to[]first.What specific scenarios should we cover in automated tests?
Unit tests for
shouldHideSingleReportField/hasEnabledListValuewith a list field wheredisabledOptionsis:[]→ not hidden[true]with 2 values) → not hiddentrue→ hiddenPlus a render test that
MoneyRequestViewReportFieldsdoesn't throw for a list field withoutdisabledOptions.What alternative solutions did you explore?
Normalize the field once, in the report-field merge in
getAvailableReportFields(disabledOptions: policyReportField.disabledOptions ?? field.disabledOptions ?? []). That covers the report view, but not fields read directly from the policy or from reportNameValuePairs, so I'd still add the guards above.aimane-chnaif commentedon Nov 17, 2026
@MelvinBot implement this
MelvinBot commentedon Nov 17, 2026
🤖 Web test steps verification results: ❌ fail
Web verification blocked by unavailable test data, not an observed App regression. The account has no reports, and supported tools cannot inject the required omitted-disabledOptions fixture.
Report renders with missing disabled flags
Blocked: account has no reports.Dropdown opens and accepts selection
Not exercised: required fixture unavailable.Disabled options remain excluded
Not exercised in the browser.Implemented in Prevent report field crashes when disabled options are missing, a draft assigned to
aimane-chnaif.Both targeted suites passed: 1,760 tests. Lint, typecheck, spelling, and Storybook smoke checks passed. Full-suite timeout and compiler/formatting-command limitations are documented in the PR.
view run · no recording available