Fix: Expense amount shown in brackets in LHN preview - #86904
cristipaval merged 27 commits into
Conversation
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
Hey, I noticed you changed If you want to automatically generate translations for other locales, an Expensify employee will have to:
Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running: npx ts-node ./scripts/generateTranslations.ts --helpTypically, you'd want to translate only what you changed by running |
|
@aimane-chnaif 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] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f4af4e2ac9
ℹ️ 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".
|
|
||
| if (isExpenseReport(report) && typeof amount === 'number' && currency) { | ||
| const formattedAmount = convertToDisplayString(Math.abs(amount), currency); | ||
| return formatReportLastMessageText(`${formattedAmount} expense${comment ? ` for ${comment}` : ''}`); |
There was a problem hiding this comment.
Localize canonical expense preview text
This branch hardcodes the preview as ${formattedAmount} expense ... instead of using a translation key, so non-English users will see English text whenever getLastMessageTextForReport() hits this canonical fallback path (for example, when the visible action resolves to CREATED after rehydration). The existing preview path uses localized strings via getReportPreviewMessage, so this introduces a locale regression specifically in the new fallback behavior.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
@aimane-chnaif I checked this flow in a non-English locale, and the LHN preview is already shown in English today (for example, BGN 24.65 expense for 34 miles in Japanese).
Should we preserve that current behavior here, or add a new translation key and localize this fallback ?
There was a problem hiding this comment.
We can support localization here
|
@aimane-chnaif, gentle bump. thanks. |
Code ReviewThe approach of building the preview from stable expense data instead of the raw message string is sound, but there are a few issues: 1. Hardcoded English strings (localization bug)
return formatReportLastMessageText(`${formattedAmount} expense${comment ? ` for ${comment}` : ''}`);This won't be translated for non-English users. The existing Note also that the existing 2. Consider reusing
|
|
Please address Melvin's review above |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
@aimane-chnaif All feedback has been addressed now. Could you please take another look when you get a chance? Thanks! |
|
@aimane-chnaif gentle bump. Thanks |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppios.moviOS: mWeb Safarimsafari.movMacOS: Chrome / Safariweb.mov |
|
@aimane-chnaif could you clarify which regression you mean here? The missing minus sign for negative expenses is a valid regression from this PR, and I’ll fix that. For the text difference, I believe the current behavior is intentional. Staging is showing the backend-provided preview text, while this PR switches the LHN fallback to the localized/client-formatted preview so the message is translated and includes the comment when available, as discussed here. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cca0c91ede
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@aimane-chnaif Thanks for reviewing again. This feedback has been addressed as well. |
|
@aimane-chnaif, friendly bump. thanks. |
|
Test cases:
|
Thanks for catching this. This regression came from my fix for the earlier issue. I updated the fallback to use the linked transaction, but missed that expense previews should prefer the description over the merchant. I’ve fixed the new fallback to use the expense description. I also found a related pre-existing production flicker before the report is fully fetched. In that path, Line 5508 in 40223f2 So after clearing cache / first load, LHN can briefly show REC-20260519173823.mp4A possible follow-up fix is to special-case expense report list previews in if (isForListPreview && isExpenseReport(report) && !isEmptyObject(linkedTransaction)) {
comment = getDescription(linkedTransaction) || originalMessage?.comment;
}Should I handle this production flicker in this PR as well? thanks |
Thanks for the detailed test cases. I’ve already tested most of these, but I’ll re-check the full set across all platforms. thanks |
|
@aimane-chnaif I tested all cases and found no regressions. Only in this one I need your confirmation:
|
No, out of scope since happening in production |
Ok, thanks. The PR and all test cases are finished from my side. Could you please re review again? thanks |
Regression AnalysisI reviewed the current state of the PR and found 1 potential regression and 1 edge case worth verifying before merge. 1. Scanned/distance expenses with merchant but no description show amount-only in LHN (Medium risk)
Impact: For scanned receipts where SmartScan detected a merchant (e.g., "Uber", "Starbucks") but the user didn't add a description, the LHN preview shows only the amount (e.g., Test: Create a manual expense with a merchant but no description → verify the LHN preview includes the merchant name after the amount. 2. Expense report with all IOU actions pending deletion and CREATED as lastReportAction (Low risk)When Confirmed OK
Recommendation: Regression #1 is the main one to verify manually — create a scanned expense with a detected merchant but no user description, and confirm the LHN preview text is acceptable. |
|
@marufsharifi please verify this to make sure we don't break production behavior. |
|
For the first case, I verified this against production and it does not appear to be a regression. When an expense has no description and only has a merchant, production also shows only the amount in the LHN preview and does not show the merchant. REC-20260522022246.mp4For the second edge case, I tried to reproduce it but could not hit that state manually. |
|
🚧 @cristipaval has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/cristipaval in version: 9.3.80-0 🚀
Bundle Size Analysis (Sentry): |
|
No help site changes required. This PR is a bug fix for the LHN expense preview display — it corrects how the preview string is built internally (using stable expense data like amount/currency/comment instead of a raw message string). The changes are limited to This doesn't introduce new features, change user-facing workflows, or modify any documented behavior, so no updates to |
|
🚀 Deployed to production by https://github.com/luacmartins in version: 9.3.81-2 🚀
|



Explanation of Change
This change fixes an inconsistency in the expense preview in the Left Hand Navigation.
Previously, the preview could change format for the same expense after opening or reselecting a report, making the UI feel unstable. Now, instead of relying on a raw message string that can be rehydrated differently, the app builds the preview from stable expense data like amount, currency, and comment. The result is a more consistent and predictable LHN preview for expense reports.
Fixed Issues
$ #83269
PROPOSAL: #83269 (comment)
Tests
Offline tests
Same as Tests.
QA Steps
Same as Tests.
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Screen.Recording.2026-04-01.at.11.04.37.PM.mov
Android: mWeb Chrome
Screen.Recording.2026-04-01.at.11.07.07.PM.mov
iOS: Native
Screen.Recording.2026-04-01.at.10.30.36.PM.1.mp4
iOS: mWeb Safari
Screen.Recording.2026-04-01.at.10.34.54.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2026-04-01.at.10.24.46.PM.mov