Skip to content

Remove unsafe assertions from emoji menus, room creation, and card settlement - #103920

Open
KJ21-ENG wants to merge 4 commits into
Expensify:mainfrom
KJ21-ENG:seatbelt-v2/batch-20261013-run-4-ff987a34
Open

KJ21-ENG wants to merge 4 commits into
Expensify:mainfrom
KJ21-ENG:seatbelt-v2/batch-20261013-run-4-ff987a34

Conversation

@KJ21-ENG

@KJ21-ENG KJ21-ENG commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Use catalog-owned emoji header keys, the existing typed header ref, option lookups for room posting/visibility, and bank-name types that accept actual account names. Room callbacks ignore values outside the offered options, and reconciliation route lookup skips an absent connection; supported selections, focus, and fallback icons are preserved.

Fixed Issues

$ #94739
PROPOSAL: #94739 (comment)

Tests

Relevant upstream TypeScript and Jest checks passed. tests/ui/EmojiPickerMenuComponentTest.tsx, tests/ui/WorkspaceNewRoomPageTest.tsx and tests/ui/DynamicWorkspaceSettlementAccountPageTest.tsx cover focus, room submission values, settlement IDs/icons and reconciliation-link visibility.

Room settings

Setup: Use an admin account allowed to create a room in the intended workspace.

  1. Open New room and choose the workspace.
  2. Set posting to Admins only and visibility to Public.
  3. Reopen and dismiss each picker without changing it. Verify the selected labels and visibility description remain correct.
  4. Enter an available room name and create the room.
  5. After it saves, open its details/settings. Verify the workspace, posting permission and visibility.
  6. Reload or reopen the app. Verify the same settings persist.
  7. Check for new console errors. Compare any errors with the same flow on base before attributing them to this PR.

Offline tests

No separate offline case is needed: the changed option callbacks use the already offered values and change no room-creation request, storage, or reconnect behavior.

QA Steps

Same as tests.

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Recordings (1)

Windows desktop Chrome: room-picker selection/dismissal and saved settings after reload were observed. Console errors occurred on reload without confirmed attribution to this PR. Native Android/iOS, mobile-web and macOS Chrome/Safari results are unverified.

01-room-picker-persistence-desktop.mp4

…nt account components

Seatbelt-Operation: e7694751-9deb-4d30-b155-87815525cae0
Seatbelt-Operation: 77793e37-f1a1-48d2-89b3-bae480b8b95a
@KJ21-ENG
KJ21-ENG marked this pull request as ready for review October 16, 2026 21:21
@KJ21-ENG
KJ21-ENG requested review from a team as code owners October 16, 2026 21:21
@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and ikevin127 and removed request for a team October 16, 2026 21:21
@melvin-bot

melvin-bot Bot commented Oct 16, 2026

Copy link
Copy Markdown

@ikevin127 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T21:47:17.961187Z 73eb411 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@melvin-bot
melvin-bot Bot removed the request for review from a team October 16, 2026 21:21

@JmillsExpensify JmillsExpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No product review required.

label={translate('newRoomPage.visibility')}
items={visibilityOptions}
onValueChange={(value) => setVisibility(value as typeof visibility)}
onValueChange={(value) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ CONSISTENCY-3 (docs)

This onValueChange handler duplicates the exact logic introduced for the writeCapability picker just above it: find the option whose value matches, and if it exists, set state to selectedOption.value. The two handlers differ only in the options array (visibilityOptions vs writeCapabilityOptions) and the setter (setVisibility vs setWriteCapability), so the shared shape should be factored out instead of copied.

Extract a small helper and reuse it for both pickers:

const getMatchingOptionValue = <T,>(options: Array<{value: T}>, value: string): T | undefined =>
    options.find((option) => option.value === value)?.value;

// writeCapability picker
onValueChange={(value) => {
    const next = getMatchingOptionValue(writeCapabilityOptions, value);
    if (next) {
        setWriteCapability(next);
    }
}}

// visibility picker
onValueChange={(value) => {
    const next = getMatchingOptionValue(visibilityOptions, value);
    if (next) {
        setVisibility(next);
    }
}}

Reviewed at: 73eb411 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Duplicated .find() guard in WorkspaceNewRoomPage.tsx is a valid find by the bot.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted the repeated lookup into one local typed findRoomOption helper used by both pickers. It returns only offered option values; missing and unmatched selections leave the current state unchanged.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the duplicated lookup through one local typed helper shared by both handlers. Added tests for valid, missing, and unmatched picker selections.

@ikevin127

ikevin127 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Screen.Recording.2026-10-17.at.17.10.43.mov

act(() => refreshEmojiWindow?.());
const {heading, host} = getEmojiHeaderHost(natureIndex, 'web');
mockFocusDescriptors.push({host, descriptor: Object.getOwnPropertyDescriptor(host, 'focus')});
// @ts-expect-error The external web host can lack focus. All remaining native host fields and ref identity stay real.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 tests/ui/EmojiPickerMenuComponentTest.tsx:700

This @ts-expect-error manufactures a host the type says can't exist. headerRef is ComponentRef<typeof View> (index.tsx:68), and on web that host is a DOM element, so focus is always there. The comment "The external web host can lack focus" is not accurate.

This leg only exists to cover the ?. in headerRef.current.focus?.() (index.tsx:86), which is a leftover from the old HTMLElement cast.

Can we call headerRef.current.focus() directly and drop this part of the test ? In a PR that removes type bypasses I'd rather not add a new one in the tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the unsupported host-without-focus test and its suppression. The web handler now calls focus directly on the supported View ref.

bankCountry: CONST.COUNTRY.US,
accountData: {type: CONST.BANK_ACCOUNT.TYPE.BUSINESS, allowDebit: true, state: CONST.BANK_ACCOUNT.STATE.SETUP, addressName: 'Chase Bank'},
});
type SettlementPageProps = PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.DYNAMIC_WORKSPACE_EXPENSIFY_CARD_SETTINGS_ACCOUNT>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 tests/ui/DynamicWorkspaceSettlementAccountPageTest.tsx:132

SettlementPageProps is the same type as WorkspaceSettlementAccountPageProps in DynamicWorkspaceSettlementAccountPage.tsx:43.

That file is already part of the PR, so can we export it from there and import it here instead of re-deriving ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exported the production WorkspaceSettlementAccountPageProps type and imported it in the test, removing the copied props definition.

Comment thread src/components/Icon/BankIconsUtils.ts Outdated
type BankIconParams = {
styles: ThemeStyles;
bankName?: BankName;
bankName?: AccountData['addressName'];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 src/components/Icon/BankIconsUtils.ts:10

AccountData['addressName'] ties a shared icon helper to one Onyx field, but the other getBankIcon callers pass card?.accountData?.bank, withdrawalIDItem.bankName and reimbursementAccount?.achData?.bankName. getBankNameKey in this same file already takes bankName: string.

Can we use bankName?: string here ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the shared icon helper's bankName input to an optional string, removing its dependency on one Onyx field's type.


function BankAccountListItemLeftElement({bankName}: {bankName: BankName}) {
type BankAccountListItemLeftElementProps = {
bankName: NonNullable<BankIconParams['bankName']>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 src/components/SettlementAccountSelector.tsx:34

With string above, this can be just bankName: string instead of NonNullable<BankIconParams['bankName']>.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified the selector prop to bankName: string and removed the derived BankIconParams type dependency.

@ikevin127

Copy link
Copy Markdown
Contributor

@KJ21-ENG Dropped (4) comments, please tag me once addressed 🙌

Seatbelt-Operation: reviewer-fix-103920-148a7b7c-46f3-4e1d-92e3-d55572edf948
Seatbelt-Operation: upstream-ci-repair-103920-7e4b3ccd-cb71-4f37-8701-8f35e50c8125
@KJ21-ENG

Copy link
Copy Markdown
Contributor Author

@ikevin127 Could you please check this once you get a chance, Thanks!

@ikevin127 ikevin127 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing my previous comments! All 5 threads (your 4 plus the bot's duplication finding) are fixed in the code ✅

@KJ21-ENG One last thing left before 🟢, please tag me once resolved and I'll approve 🙌

Comment on lines +191 to +194
// Upstream adds an optional pending-state argument. These settings have no pending update.
for (const call of settlementCalls) {
expect(call.slice(6)).toStrictEqual(call.length === 6 ? [] : [false]);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 tests/ui/DynamicWorkspaceSettlementAccountPageTest.tsx:191 These assertions are written to pass whether updateSettlementAccount gets 6 or 7 arguments (call.length === 6 ? [] : [false]), because the branch is behind main. Once merged, the 6-argument case can never happen, and the conditional only makes it unclear what the page is expected to pass.

Please merge main and assert the exact call instead, here and at line 222 below:

expect(updateSettlementAccount).toHaveBeenNthCalledWith(1, 'example.com', fundID, policyID, programKey, 22, 11, false);
expect(updateSettlementAccount).toHaveBeenNthCalledWith(2, 'example.com', fundID, policyID, programKey, 33, 11, false);

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants