Skip to content

Show the debited and reimbursed amounts on the reconciliation dashboard - #97167

Open
ishpaul777 wants to merge 15 commits into
Expensify:mainfrom
ishpaul777:ishpaul/655931-reconciliation-fx-columns
Open

Show the debited and reimbursed amounts on the reconciliation dashboard#97167
ishpaul777 wants to merge 15 commits into
Expensify:mainfrom
ishpaul777:ishpaul/655931-reconciliation-fx-columns

Conversation

@ishpaul777

@ishpaul777 ishpaul777 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Grouped by Withdrawal ID, the dashboard only showed the report total. A cross-border settlement debits the company and credits the employee in different currencies, so one number cannot describe it.

Adds Amount debited and Amount reimbursed between Expenses and Total, each in its own currency, from Auth #23263.

  • Visibility. The columns appear once a group in the results has an amount and its currency, the way the report list already handles the submitter columns. The issue asked to gate on being an admin of a workspace with a global reimbursement bank account, which the client cannot tell: the policy payload only carries achAccount, while Auth derives global reimbursement from the policy's reimbursement countries. Gating on the data lands in the same place.
  • Sorting. Both columns sort. Neither side converts between currencies: the server ranks the amounts as stored to pick the page, and the client then orders that page the same way, so a group can outrank one worth more in another currency. The client sort is the one you see - Search never reads the ordering the backend sends, so a column with no local sort key never reorders at all.
  • Translations. Hand-written because generateTranslations skips pull requests from forks.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/655931
PROPOSAL: N/A - internal issue

Tests

  1. Sign in as an admin of a workspace with global reimbursements enabled and at least one cross-border reimbursement that has settled.
  2. Go to Reports, then the Reconciliation tab (Search grouped by Withdrawal ID).
  3. On an account that has never customized the reconciliation columns, verify the table shows Amount debited and Amount reimbursed between Expenses and Total.
  4. Verify the cross-border settlement row shows the debited amount in the company's settlement currency and the reimbursed amount in the employee's deposit currency, and that they differ.
  5. Verify a domestic settlement row leaves both cells blank.
  6. Open the column picker, uncheck Amount debited, and verify the column and its header disappear and the rest of the table stays aligned.
  7. On an account that had already saved a custom set of reconciliation columns, verify neither column shows up until it is checked in the column picker. Saved preferences replace the defaults rather than being merged with them, so the two new columns start off for these accounts.
  8. Sign in as an admin whose settlements are all domestic and verify neither column appears at all.
  9. Click the Amount debited header and verify the rows reorder by that amount, and that clicking it again flips the order. Repeat for Amount reimbursed.
  10. Verify sorting by Withdrawn, Expenses and Total still works.
  • Verify that no errors appear in the JS console

Offline tests

  1. Load the Reconciliation tab while online, then turn off the network connection.
  2. Verify the previously loaded groups still render both amounts from the cached snapshot.
  3. Verify no error or blank state appears for the two columns while offline.

QA Steps

Same as tests, using a staging account that is an admin of a workspace with global reimbursements enabled and a settled cross-border reimbursement.

  • 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 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.
  • 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

Screen.Recording.2026-08-03.at.8.03.34.PM.mov

@melvin-bot

melvin-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

Hey, I noticed you changed src/languages/en.ts in a PR from a fork. For security reasons, translations are not generated automatically for PRs from forks.

If you want to automatically generate translations for other locales, an Expensify employee will have to:

  1. Look at the code and make sure there are no malicious changes.
  2. Run the Generate static translations GitHub workflow. If you have write access and the K2 extension, you can simply click: [this button]

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 --help

Typically, you'd want to translate only what you changed by running npx ts-node ./scripts/generateTranslations.ts --compare-ref main

@ishpaul777

Copy link
Copy Markdown
Contributor Author

@MelvinBot review

@ishpaul777

Copy link
Copy Markdown
Contributor Author

@codex review

ishpaul777 and others added 3 commits July 28, 2026 06:26
SortableTableHeader only makes a header pressable when isColumnSortable
is set, so without it the columns rendered as plain labels and the sort
Auth supports could not be reached.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
getSortedData re-sorts the page by the mapped property, which for these
two columns is a raw amount in whichever currency that settlement used.
Ranking GBP 10250 against USD 12000 that way puts them in the wrong
order. Unmapped columns fall through with the data untouched, which is
the order Auth already computed from a common-currency sort key.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
typecheck and TranslateTest both fail on a key that only exists in
en.ts. The generateTranslations bot skips pull requests from forks, so
these are written by hand.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Reviewed the diff. The visibility gating, types, styles, parser regen, and the two column-availability tests all look clean and match the existing patterns. One blocker on the sorting behavior, plus a design question and a minor nit.

🔴 The two new columns aren't actually sortable

The PR description says "Both columns are sortable" and Test step 8 asks to click the Amount debited / Amount reimbursed headers to reorder — but the new header configs are missing isColumnSortable: true:

SearchTableHeader.tsx:411-418 — unlike groupExpensesHeader and groupTotalHeader (which set isColumnSortable: true), the two new entries set neither true nor false, so the flag is undefined.

In SortableTableHeader.tsx:79 sortability is shouldShowSorting && isColumnSortable, so undefined → the header renders non-clickable and never fires onSortPress. The sort mapping you added at SearchUIUtils.ts:370-371 is therefore dead code today. Add isColumnSortable: true to both header entries.

🟡 Once sortable, the client sorts by the raw per-currency amount

The description argues raw amounts can't be ranked across currencies and that the server ranks via a hidden converted key. But grouped results are re-sorted client-sidegetSortedSectionsgroupBySortFunction[WITHDRAWAL_ID]getSortedData always runs in useSearchSnapshot/SearchStaticList — and your mapping points at the raw debitedAmount / creditedAmount fields, so the displayed order will be by raw magnitude, not the server's converted key. (This mirrors the existing groupTotal → 'total' mapping, so it may be acceptable, but it contradicts the reasoning in the description.) Worth confirming once you flip the sortable flag that the resulting order is what you intend — there's no converted key on the client SearchWithdrawalIDGroup type to sort by.

🟢 Minor: falsy guard hides a zero amount

WithdrawalIDListItemHeader.tsx:189 (and L202) gate on !!debitedAmount && !!debitedCurrency. A legitimate 0 amount would be treated as absent and the cell left blank. Almost certainly a non-issue for a real settlement, and negatives (the test uses -10000) are fine — just flagging in case a zeroed conversion is possible.


Everything else looks good — nice touch adding the ColumnAvailability guard entries so the new columns force a deliberate picker decision, and the visibility tests cover both the domestic-hidden and missing-currency cases.

@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: 3d7bcaccf9

ℹ️ 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 src/libs/SearchUIUtils.ts
Comment thread src/components/Search/SearchTableHeader.tsx
@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/CONST/index.ts 94.81% <ø> (ø)
.../components/Search/FilterDropdowns/SortByPopup.tsx 3.03% <ø> (ø)
src/components/Search/hooks/useSearchSnapshot.ts 87.64% <ø> (ø)
src/hooks/useSearchOverlay.tsx 55.88% <ø> (ø)
src/components/Search/SortableTableHeader.tsx 43.47% <0.00%> (-1.98%) ⬇️
src/components/Search/SearchTableHeader.tsx 49.43% <0.00%> (-1.14%) ⬇️
src/libs/SearchUIUtils.ts 65.15% <84.21%> (+0.03%) ⬆️
src/styles/utils/index.ts 55.87% <0.00%> (-0.27%) ⬇️
...SearchList/ListItem/WithdrawalIDListItemHeader.tsx 0.00% <0.00%> (ø)
src/libs/SearchParser/searchParser.js 84.75% <90.63%> (-0.63%) ⬇️
... and 1 more
... and 149 files with indirect coverage changes

The list is built at module scope, so the name resolves the moment the
file loads and grouping by category throws instead of rendering.
The helper answered "does this column have data" for every column,
which read as a double negative for the ones it knows nothing about.
Bail out on a transaction array first, then ask the question only of
the two conversion columns, matching the expense report branch above.
The server communicates its order through orderedKeys, which the client
never reads, so a column with no sorting property leaves the rows in the
order the response object happened to be keyed in and clicking the
header does nothing. Point both columns at their amount, the way the
total column already works.
@ishpaul777

Copy link
Copy Markdown
Contributor Author

@MelvinBot final review this

@MelvinBot

Copy link
Copy Markdown
Contributor

Final review

LGTM — the change is well-scoped and complete. The two currency-aware columns are wired through the whole stack consistently, and the edge cases you'd worry about are covered. A couple of non-blocking observations below.

What I verified
  • Both parsers regenerated. group-amount-debited / group-amount-reimbursed are present in both searchParser.js and autocompleteParser.js, matching the new baseRules.peggy rules — so the generated files aren't stale.
  • All 10 locales updated with both amountDebited / amountReimbursed keys (en, es, fr, it, de, nl, pl, ja, zh-hans, pt-BR).
  • Completeness guard is satisfied. Both new columns are added to the COLUMN_AVAILABILITY single-source-of-truth set in ColumnAvailabilityTest.ts, so the "every TABLE_COLUMNS value is classified" test won't fail.
  • Visibility gating is sound. hasGroupWithConversionAmount requires both amount and currency, and the filter only applies to conversion columns — other groupBy paths pass through untouched. The Array.isArray(data) early-return keeps the non-Onyx-map callers safe. Unit tests cover the domestic-only, cross-border, and missing-currency cases.
  • Per-row blanking matches the gatingthe header cells only render a TotalCell when the row itself has amount + currency, so a domestic row inside a mixed page stays blank.

Observations (non-blocking)

  1. The PR description's "Sorting" bullet contradicts the final code. It says "The client deliberately does not sort these two locally", but the sorting map adds debitedAmount / creditedAmount as local sort keys, and both a unit test and the last commit ("Order the page by the conversion amounts the row shows") confirm the client does sort locally. This is fine as implemented — it's the same raw-number behavior GROUP_TOTAL already uses — but the description prose is stale and could mislead QA. Worth updating so it matches steps 8 and the code comment.

  2. Zero-amount edge. Gating on !!amount (both in the row cell and hasGroupWithConversionAmount) treats a genuine converted amount of 0 as absent. Almost certainly irrelevant for real cross-border settlements, just flagging it since it's a truthiness check rather than a !== undefined.

Neither blocks merge — nice, clean PR.

@ishpaul777
ishpaul777 marked this pull request as ready for review July 31, 2026 14:56
@ishpaul777
ishpaul777 requested review from a team as code owners July 31, 2026 14:56
@melvin-bot
melvin-bot Bot requested review from huult and removed request for a team July 31, 2026 14:56
@melvin-bot

melvin-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

@huult 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 requested review from flaviadefaria and removed request for a team July 31, 2026 14:56

@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: d6f26227d3

ℹ️ 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 src/libs/SearchUIUtils.ts Outdated
return result;
}

return result.filter((column) => !isConversionAmountGroupColumn(column) || hasGroupWithConversionAmount(column, data));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep conversion columns available while results are paginated

When a withdrawal search has more pages and the currently loaded page contains only domestic settlements, this filter removes both conversion columns even if later pages contain cross-border groups. This also makes both fields unavailable in the Sort By popup; after sorting a populated amount column ascending, the backend can return all empty domestic groups first, causing the active column and its header to disappear until enough additional pages are loaded. Defer the absence-based hiding until all results are loaded, or use result-level metadata rather than inspecting only the accumulated page data.

Useful? React with 👍 / 👎.

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.

@ishpaul777 Could you take a look at this comment?

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 3e0d2ec - the column the results are sorted by now stays visible even when no loaded group carries that amount, so the header and the Sort by option survive an all-domestic first page.

@shawnborton

Copy link
Copy Markdown
Contributor

Let us know when there are screenshots to review.

@huult

huult commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

sure

@huult

huult commented Aug 2, 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.
  • 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

@huult

huult commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@ishpaul777 Could you record a video and attach it to checklist?

Sorting ascending puts the groups without that amount first, so an all-domestic
first page would drop the column, taking the header and the Sort by option with it.
@ishpaul777

Copy link
Copy Markdown
Contributor Author

@ishpaul777 Could you record a video and attach it to checklist?

done!

@huult

huult commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@ishpaul777 Could you sync with main to resolve the conflict?

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.

4 participants