Skip to content

Show balance and remaining limit for Plaid company card feeds#94096

Draft
ishpaul777 wants to merge 3 commits into
Expensify:mainfrom
ishpaul777:ishpaul777/93198-company-card-balance-frontend
Draft

Show balance and remaining limit for Plaid company card feeds#94096
ishpaul777 wants to merge 3 commits into
Expensify:mainfrom
ishpaul777:ishpaul777/93198-company-card-balance-frontend

Conversation

@ishpaul777

Copy link
Copy Markdown
Contributor

Explanation of Change

Displays a balance block (Current balance + Remaining limit) above the company cards table for Plaid-connected (direct) feeds, mirroring the pattern on the Expensify Card page.

  • Adds currentBalance, remainingLimit, and balanceTimestamp (all in cents / datetime) to the company card feed type (CustomCardFeedData). These are populated by the backend from Plaid (see backend PR below).
  • New WorkspaceCompanyCardsBalanceLabels renders the two stats above the table; each stat (WorkspaceCompanyCardsBalanceLabel) has an info tooltip showing the last-updated timestamp reported by the bank.
  • Display rules, per the issue:
    • Non-Plaid feed -> block hidden (gated on isDirectFeed).
    • Plaid feed but no balance data -> block hidden.
    • Partial data (e.g. no remaining limit) -> that field shows "Not available".
    • Full data -> both values shown.
  • No cash back item for company cards (confirmed in the issue; Plaid does not provide it).

Depends on backend PR: https://github.com/Expensify/Web-Expensify/pull/53882 — that PR fetches the balance from Plaid and stores it on the feed (in cents). This PR is display-only and is safe to merge after it.

Note: amounts are displayed in the policy's output currency (fallback USD), consistent with the rest of the company cards page.

Fixed Issues

$ #93198
PROPOSAL: N/A (internal)

Tests

  1. As a workspace admin, open Workspace > Company cards and select a Plaid-connected feed.
  2. Verify a balance block appears above the table showing Current balance and Remaining limit.
  3. Tap the ⓘ next to each — verify a tooltip shows the description and the last-updated timestamp.
  4. Select a non-Plaid feed (commercial/CSV) — verify the balance block is hidden.
  5. For a feed where the bank reports no limit, verify Remaining limit shows "Not available".
  • Verify that no errors appear in the JS console

Offline tests

  1. Go offline and open the company cards page for a Plaid feed.
  2. Verify the previously loaded balance block still renders from cached Onyx data.

QA Steps

  1. Same as Tests above, on a staging account with a Plaid-connected company card feed.
  • 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 verified there are no console errors
  • I followed proper code patterns
  • I verified any copy / text that was added to the app is grammatically correct in English (capitalization: only first word of labels)
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed
  • If any new file was added I verified it has a description at the top if not self explanatory

Screenshots/Videos

Pending — UI screenshots/recordings to be added once running against the backend PR locally.

-- written by claude on Ishpaul's Behalf

Display a balance block (current balance + remaining limit) above the
company cards table for Plaid-connected feeds, mirroring the Expensify
Card page. Each stat has an info tooltip with the last-updated timestamp
reported by the bank. The block is hidden for non-Plaid feeds and when no
balance data is available, and shows "Not available" for a field the bank
did not report.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ishpaul777 ishpaul777 requested review from a team as code owners June 19, 2026 21:38
@melvin-bot

melvin-bot Bot commented Jun 19, 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

@melvin-bot melvin-bot Bot requested review from truph01 and removed request for a team June 19, 2026 21:38
@melvin-bot

melvin-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown

@truph01 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 trjExpensify and removed request for a team June 19, 2026 21:38
@ishpaul777 ishpaul777 marked this pull request as draft June 19, 2026 21:39
@ishpaul777

Copy link
Copy Markdown
Contributor Author

draft WIP for now will open soon

ishpaul777 and others added 2 commits June 20, 2026 03:10
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

const [isVisible, setVisible] = useState(false);
const [anchorPosition, setAnchorPosition] = useState({top: 0, left: 0});
const anchorRef = useRef(null);

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 component is a near-duplicate of the existing src/pages/workspace/expensifyCard/WorkspaceCardsListLabel.tsx. The anchor-positioning useEffect (with the identical BOTTOM_MARGIN_OFFSET = 3 constant), the Icon + PressableWithFeedback header block, and the Popover tooltip block are copied almost verbatim. Duplicating this logic doubles the maintenance surface and bug risk.

Extract the shared label/tooltip UI (anchor positioning + popover + info button) into a reusable component or hook that both the Expensify Card and Company Cards balance labels consume, parameterizing only the differing bits (translation key prefix, value formatting, optional CTA). For example, a shared CardBalanceLabel that takes titleKey, descriptionKey, and displayValue props.


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

<Text style={styles.shortTermsHeadline}>{displayValue}</Text>
<Popover
onClose={() => setVisible(false)}
isVisible={isVisible}

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.

❌ UI-3 (docs)

innerContainerStyle={!shouldUseNarrowLayout ? {maxWidth: variables.modalContentMaxWidth} : undefined} passes an inline style object literal to a *Style prop. {maxWidth: variables.modalContentMaxWidth} is a fully static value that belongs in the shared style system; the inline literal creates a new object every render and bypasses the styles helpers.

Add a named style (e.g. styles.popoverMaxWidth returning {maxWidth: variables.modalContentMaxWidth}) in the style sheet and reference it: innerContainerStyle={!shouldUseNarrowLayout ? styles.popoverMaxWidth : undefined}.


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

left: position.left,
});
}, [isVisible, windowWidth]);

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-8 (docs)

format(new Date(lastUpdated.replace(' ', 'T')), CONST.DATE.FNS_DATE_TIME_FORMAT_STRING) formats a user-visible timestamp (shown in the tooltip) with a hardcoded yyyy-MM-dd HH:mm:ss pattern, bypassing the project's locale-aware date helpers. The displayed date order/separators will not respect the user's locale.

Format the timestamp through the localization layer (e.g. DateUtils.datetimeToCalendarTime / the date helpers exposed by useLocalize) so the last-updated time honors the user's locale.


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

@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
...onents/Tables/WorkspaceCompanyCardsTable/index.tsx 0.00% <0.00%> (ø)
...ompanyCards/WorkspaceCompanyCardsBalanceLabels.tsx 0.00% <0.00%> (ø)
...companyCards/WorkspaceCompanyCardsBalanceLabel.tsx 0.00% <0.00%> (ø)
... and 12 files with indirect coverage changes

@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: 3151435db5

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

}, [isVisible, windowWidth]);

const displayValue = value === undefined ? translate('workspace.companyCards.balance.notAvailable') : convertToDisplayString(value, currency);
const formattedLastUpdated = lastUpdated ? format(new Date(lastUpdated.replace(' ', 'T')), CONST.DATE.FNS_DATE_TIME_FORMAT_STRING) : undefined;

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 Use UTC-aware formatting for balance timestamps

When the backend sends balanceTimestamp in the same DB format used elsewhere (yyyy-MM-dd HH:mm:ss, serialized as UTC without a Z), this parses it as a local device time because the replacement does not add a timezone. In non-UTC timezones the tooltip will show a shifted “last updated” time compared with existing company-card timestamps that go through getLocalDateFromDatetime, so admins can see incorrect balance freshness.

Useful? React with 👍 / 👎.

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.

1 participant