Skip to content

Expense submission crashes with 'TypeError: t is not iterable' when policyRecentlyUsedCurrencies is not hydrated #84464

@blimpich

Description

@blimpich

Description

When submitting an expense on the confirmation page, the app crashes with TypeError: t is not iterable if policyRecentlyUsedCurrencies has not been hydrated by Onyx yet (i.e. is undefined or null).

The crash occurs in mergePolicyRecentlyUsedCurrencies at src/libs/actions/IOU/index.ts:3795 when attempting to spread policyRecentlyUsedCurrencies into an array:

const currenciesWithNew = [currency, ...policyRecentlyUsedCurrencies];

The sibling function mergePolicyRecentlyUsedCategories already has a defensive Array.isArray() check, but mergePolicyRecentlyUsedCurrencies does not.

Sentry Issues

Both share the same stacktrace through IOURequestStepConfirmation → requestMoney → getMoneyRequestInformation → mergePolicyRecentlyUsedCurrencies.

Expected Behavior

Expense submission should succeed even when policyRecentlyUsedCurrencies hasn't been hydrated from Onyx yet.

Actual Behavior

App crashes with TypeError: t is not iterable, blocking the user from submitting the expense.

Proposed Fix

Add the same Array.isArray() defensive check used in mergePolicyRecentlyUsedCategories:

const currenciesArray = Array.isArray(policyRecentlyUsedCurrencies) ? policyRecentlyUsedCurrencies : [];

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions