Skip to content

refactor: narrow plan, currency, chart, and video preview values - #103226

Merged
blimpich merged 11 commits into
Expensify:mainfrom
KJ21-ENG:seatbelt-v2/fresh-20261006-9-3361c0df
Nov 11, 2026
Merged

blimpich merged 11 commits into
Expensify:mainfrom
KJ21-ENG:seatbelt-v2/fresh-20261006-9-3361c0df

Conversation

@KJ21-ENG

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

Copy link
Copy Markdown
Contributor

Explanation of Change

Remove unsafe type assertions from five production paths: workspace plan selection, upgrade artwork lookup, preferred currency, video attachment preview, and chart label units. Preserve the supported plan choices, currency precedence, artwork lookup, and chart formatting. The video preview accepts a nullable source-load event before requesting a thumbnail.

Changed files
  • src/pages/workspace/DynamicWorkspaceOverviewPlanTypePage.tsx
  • src/pages/workspace/upgrade/UpgradeIntro.tsx
  • src/hooks/usePreferredCurrency.ts
  • src/components/AttachmentPreview.tsx
  • src/components/Charts/hooks/useChartLabelFormats.ts
  • tests/unit/DynamicWorkspaceOverviewPlanTypePageTest.tsx
  • tests/unit/UpgradeIntroTest.tsx
  • tests/unit/usePreferredCurrencyTest.tsx
  • tests/unit/AttachmentPreviewTest.tsx
  • tests/unit/components/Charts/useChartLabelFormats.test.ts

Fixed Issues

$ #94739
PROPOSAL: #94739 (comment)

Tests

Use a signed-in ordinary test account that owns a Collect workspace.

1. Chart label

Precondition: the account has at least 3 USD expenses with different categories.

  1. Open Reports > Expenses.
  2. Open Display and set Group by to Category.
  3. Set View to Bar.
  4. Verify that the amount labels on the chart show the currency symbol, for example $10.
  5. Set View to Line.
  6. Verify that the amount labels on the chart show the currency symbol in the same way.

2. Video preview (Android and iOS apps only, because sharing into Expensify uses the phone's share sheet)

Precondition: a short MP4 video is saved in the phone's photo gallery.

  1. Open the photo gallery and select the video.
  2. Tap Share and choose Expensify.
  3. Choose any chat.
  4. Verify that the Share details page shows a thumbnail of the video under Attachment.
  5. Tap the thumbnail.
  6. Verify that the video opens and plays.

3. Preferred currency

Precondition: the account has no payment card added.

  1. Open Settings > Subscription.
  2. Verify that the plan price is shown in the account's local currency when it is USD, AUD, GBP, NZD or EUR, and in USD for any other currency.
  3. Tap Add payment card.
  4. Verify that the card form uses the same currency as step 2.

4. Workspace upgrade

Precondition: the Collect workspace has not been upgraded. Do not complete an upgrade during this test.

  1. Open Workspaces, select the Collect workspace, then open Overview > Plan type.
  2. Verify that each plan shows its name and description, and Collect is selected.
  3. Go back and open Workflows. Select the Advanced Approvals upgrade preview.
  4. Verify that the title, description, price and illustration appear, and the illustration is not cropped or stretched.
  5. Go back without upgrading.

Unit tests also cover these paths: useChartLabelFormats.test.ts, AttachmentPreviewTest, usePreferredCurrencyTest, DynamicWorkspaceOverviewPlanTypePageTest and UpgradeIntroTest.

  • Verify that no errors appear in the JS console

Offline tests

N/A for additional offline testing: the changes do not alter a network, persistence, retry, or reconnect path.

QA Steps

Same as tests.

  • Verify that no errors appear in the JS console

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 verified any copy / text that was added to the app 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 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 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

Screenshots/Videos (1)

Advanced Approvals artwork desktop and phone-sized

PR-103226-C01-DM.mp4

Seatbelt-Operation: 4026f6b9-f9fe-4443-8cfd-07e619ccd7e8
Seatbelt-Operation: f8a19569-0abb-429e-a2e3-094cbd2debbc
Seatbelt-Operation: c422ddda-3c1b-403c-b8a4-eba3a6a14e3b
Seatbelt-Operation: 6df47529-1e13-4f81-ad41-bc184395612d
Seatbelt-Operation: 9ebe2014-21ca-44ee-b434-1dca06dab3fa
@KJ21-ENG KJ21-ENG changed the title Remove unsafe type assertions from workspace plans, currency, charts, and video preview [WIP] refactor: narrow plan, currency, chart, and video preview values Oct 23, 2026
Seatbelt-Operation: main-20261030-103226-sign-494695ff-8d74-45c5-ab3f-23e8a4e94739
@KJ21-ENG KJ21-ENG changed the title [WIP] refactor: narrow plan, currency, chart, and video preview values refactor: narrow plan, currency, chart, and video preview values Oct 30, 2026
@KJ21-ENG
KJ21-ENG marked this pull request as ready for review November 2, 2026 11:24
@KJ21-ENG
KJ21-ENG requested review from a team as code owners November 2, 2026 11:24
@melvin-bot
melvin-bot Bot requested review from garrettmknight and situchan and removed request for a team November 2, 2026 11:24
@melvin-bot

melvin-bot Bot commented Nov 2, 2026

Copy link
Copy Markdown

@situchan 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]

@melvin-bot
melvin-bot Bot removed the request for review from a team November 2, 2026 11:24
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 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-11-02T11:47:46.489353Z 4914605 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4914605d05

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/unit/UpgradeIntroTest.tsx Outdated
// Given no feature was selected
// When the real upgrade intro renders
render(<UpgradeIntro onUpgrade={jest.fn()} />);
// Then the generic view is shown

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Explain why the new test expectations must hold

These Given/When/Then comments only repeat the adjacent render and expect; they do not explain why an unselected feature must fall back to the generic upgrade view. The Testing rule in AGENTS.md requires comments explaining why, and CONSISTENCY-14 prohibits comments that merely restate the code. Document the invariant or regression this scenario protects, and replace equivalent boilerplate in the other new tests, so future maintainers can distinguish intended behavior from incidental assertions.

AGENTS.md reference: AGENTS.md:L92-L92

Useful? React with 👍 / 👎.

@KJ21-ENG KJ21-ENG Nov 2, 2026 •

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.

Fixed in f93eb56. The Given/When/Then comments in the 14 new tests now explain why each behavior holds instead of restating the code.

Reword the Given/When/Then comments in the tests this PR added so they state the reason for each behavior. Comments only.

Addresses Expensify#103226 (comment)

Seatbelt-Operation: repair-codex-103226-sign-998d2349-438f-4c5d-b8d1-edfaf07d4f93
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@garrettmknight
garrettmknight removed their request for review November 2, 2026 19:53
Seatbelt-Operation: merge-main-20261103-103226-sign-825c6367-0299-47ce-9c92-f004db296f80
@KJ21-ENG

KJ21-ENG commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

@situchan Could you please take a look at this when you get a chance, Thanks!

Seatbelt-Operation: merge-main-20261106-103226-sign-9b73006f-fd67-4113-ab83-7e2a8a79b984
Comment on lines +119 to +126
const illustrationIcon = Object.entries(illustrationIcons).find(([name]) => name === feature.icon)?.[1];
const illustration = Object.entries(illustrations).find(([name]) => name === feature.icon)?.[1];
const isIllustration = feature.icon in illustrations;
const isIllustrationIcon = feature.icon in illustrationIcons;
let iconSrc;
if (isIllustrationIcon) {
iconSrc = illustrationIcons[feature.icon as keyof typeof illustrationIcons];
if (feature.icon in illustrationIcons) {
iconSrc = illustrationIcon;
} else if (isIllustration) {
iconSrc = illustrations[feature.icon as keyof typeof illustrations];
iconSrc = illustration;

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.

Icon lookup done twice

illustrationIcon and illustration are already found with Object.entries(...).find, but the in checks are kept to pick between them.

Fix: const iconSrc = illustrationIcon ?? illustration; and drop the in checks.

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.

Done. It now uses const iconSrc = illustrationIcon ?? illustration;. isIllustration is now illustration !== undefined, so all the in checks are gone.

…y check

Address review: iconSrc is illustrationIcon ?? illustration, and isIllustration comes from the found
illustration, so the in checks are gone.
Pass the upgradeSentryLabel prop that main made required in the UpgradeIntro tests.
@situchan

situchan commented Nov 11, 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 any copy / text that was added to the app 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 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 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

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
test.mov
test2.mov

@situchan

Copy link
Copy Markdown
Contributor

Please update Tests steps to be more readable.
I am quite hard to follow at the moment.

Like this:
Precondition:
1.
2.
3.
4. Verify that ...

There should be 4 test cases (chart label, video preview, preferred currency, workspace upgrade)

@KJ21-ENG

Copy link
Copy Markdown
Contributor Author

Updated. The Tests section now has the 4 cases you listed: chart label, video preview, preferred currency and workspace upgrade. Each has a precondition, numbered steps and a "Verify that …" check.

@KJ21-ENG

Copy link
Copy Markdown
Contributor Author

@situchan Both points are addressed: the icon lookup now uses illustrationIcon ?? illustration, and the Tests section is rewritten into 4 clear cases. I also merged main. Please take another look.

@melvin-bot
melvin-bot Bot requested a review from blimpich November 11, 2026 10:40

@blimpich blimpich 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.

LGTM

– written by Claude on Ben's behalf

@blimpich
blimpich merged commit c32da91 into Expensify:main Nov 11, 2026
38 of 42 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 blimpich has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

Copy link
Copy Markdown
Contributor

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/blimpich in version: 9.5.37-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed — this PR refactors type handling while preserving existing user-facing behavior, adds no new workflow, and makes no existing article sentence incorrect.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.5.37-1 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 failure ❌
🍎 iOS 🍎 failure ❌

Bundle Size Analysis (Sentry):

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.

5 participants