App icon indicating copy to clipboard operation
App copied to clipboard

[Due for payment 2026-11-23] [CFI] [$250] Add “Last synced” column to workspace Company cards

Open melvin-bot[bot] opened this issue 3 weeks ago • 69 comments

Admins currently open each card’s details to see its last update. Show this timestamp directly in the Company cards list.

  • Use the existing lastScrape value.
  • Clarify that it means the last successful sync.
  • Handle missing timestamps and unassigned cards.
  • Keep compact layouts readable.

Reported by @garrettmknight via DM with MelvinBot

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @samarroy84

melvin-bot[bot] avatar Nov 04 '26 18:11 melvin-bot[bot]

Triggered auto assignment to Contributor-plus team member for initial proposal review - @mkhutornyi (External)

melvin-bot[bot] avatar Nov 04 '26 18:11 melvin-bot[bot]

Job added to Upwork: https://www.upwork.com/jobs/~022118055643648118256

melvin-bot[bot] avatar Nov 04 '26 18:11 melvin-bot[bot]

Proposal

What is the root cause of that problem?

This is a new feature. The card's lastScrape timestamp is already in Onyx, but it is only read in DynamicWorkspaceCompanyCardDetailsPage (the "Last updated" row) and in the CSV export in WorkspaceCompanyCardsTableControls. WorkspaceCompanyCardsTable/index.tsx never adds a column for it (CompanyCardsTableColumnKey is member | card | customCardName | exportAccount | actions), and WorkspaceCompanyCardsTableRow has no cell for it.

What changes do you think we should make in order to solve the problem?

  1. One shared formatter. Add a small helper in CardUtils (e.g. getCompanyCardLastSyncedText(card, translate)) that returns:
    • updating ("Updating...") while card.isLoadingLastUpdated is true, so the cell matches the details page after "Update card";
    • the formatted local time of lastScrape when it exists;
    • neverUpdated ("Never") for an assigned card with no lastScrape. Reuse it on the details page and in the CSV export, which currently format lastScrape separately.
  2. Column. Add a lastSynced key to CompanyCardsTableColumnKey and a column after "Card name" (before the optional "Export account" column) with a new workspace.moreFeatures.companyCards.lastSynced: 'Last synced' label in all language files. It uses styles.mnw0 and dynamicSizing with shouldFitContent like the card column, so it stays narrow.
  3. Row data and cell. In cardsData, add lastSyncedText (from the helper, only for assigned cards) and the raw lastScrape for sorting. In WorkspaceCompanyCardsTableRow, render a TextWithTooltip cell under the same !shouldUseNarrowTableLayout guard as the other secondary columns, and add the value to the row's accessibilityLabel.
    • Clarify meaning: show a compact date/time in the cell, and set the tooltip to the full timestamp with a short explanation, e.g. "Last successful sync: 2026-11-04 18:54". The details page row label can use the same wording so both places agree.
    • Unassigned cards: leave the cell empty. There is no card object, so there is nothing to sync.
  4. Sorting. Make the column sortable. In compareItems, compare lastScrape timestamps, put cards with no timestamp last, and break ties by card name. This follows the existing exportAccount branch. The existing assigned/unassigned grouping stays as it is.
  5. Compact layouts. On narrow and medium widths (shouldUseNarrowTableLayout), the column is hidden like Card, Card name and Export account. The value is still on the card's details page, so the narrow row stays at two lines.

Tests: unit tests for the helper (timestamp, missing timestamp, updating state) and for sorting by lastSynced (missing timestamps last, ties by card name, unassigned cards stay grouped). Also a UI test that the column renders on wide layouts, is absent on narrow ones, and shows an empty cell for unassigned cards.

What alternative solutions did you explore? (Optional)

  • Showing "Last synced" as a third subtitle line in the narrow layout. That makes every mobile row taller for a value most admins only need on desktop, so I'd keep it on the details page there.
  • Relative times ("2 hours ago"). These are easier to scan, but they go stale while the page is open and are harder to compare with the CSV export. An absolute local time with the explanation in the tooltip is simpler.

bash-king avatar Nov 04 '26 19:11 bash-king

📣 @bash-king! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

melvin-bot[bot] avatar Nov 04 '26 19:11 melvin-bot[bot]

Proposal

What is the root cause of that problem?

The Company cards list never renders lastScrape, although assigned rows already receive it. This is missing presentation, not evidence of broken syncing.

What changes do you think we should make in order to solve the problem?

Add a Last synced column and matching row cell. For narrow and medium layouts, show a labeled line beneath existing card information.

Use these display rules:

  • Explain that the timestamp means last successful sync.
  • Reuse details’ timezone-aware formatting; guard missing or invalid values.
  • Show “Never” for assigned cards without a timestamp and “—” for unassigned cards, whose sync history is unavailable.
  • Retain the previous successful timestamp during pending or failed syncs. No new API is needed for assigned cards.
Evidence and validation — medium confidence

Test assigned, unassigned, missing/invalid timestamps, timezone conversion, pending/failed syncs, and wide/medium/narrow layouts. Code inspection only; browser behavior and backend writers were not independently verified. Production logs are unnecessary to establish this presentation omission.


Next Steps for Contributor+ team: To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/105949#issuecomment-6639518951) to create a draft PR. To refine: @MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.

MelvinBot avatar Nov 04 '26 19:11 MelvinBot

@MelvinBot draft PR for testing

mkhutornyi avatar Nov 04 '26 19:11 mkhutornyi

Proposal

Please re-state the problem that we are trying to solve in this issue

Add a "Last synced" column to the workspace Company Cards table to clearly display when the company card feed/transactions were last updated.

What is the root cause of that problem?

This is a feature request. Currently, WorkspaceCompanyCardsTable/index.tsx defines table columns (member, card, customCardName, exportAccount, actions) and constructs tableData from Onyx cardList and cardFeeds. In Onyx, company card feeds track scrape status via lastScrape (or lastSuccessfulScrape on the feed/card settings). Currently, there is no column exposing this sync timestamp to workspace admins.

What changes do you think we should make in order to solve the problem?

  1. Translations in src/languages/en.ts: Add the new key under workspace.companyCards:
lastSynced: 'Last synced',
  1. Data Mapping in WorkspaceCompanyCardsTable/index.tsx: In the item mapping where WorkspaceCompanyCardTableItemData is constructed:
  • Extract lastScrape from assignedCard?.lastScrape ?? cardFeed?.lastScrape.
  • Compute formatted display string:
const lastSyncedText = lastScrape ? DateUtils.formatToLocalTime(lastScrape) : '-';
  • Map lastSyncedText and lastScrapeTimestamp into the row item data.
  1. Column Definition in WorkspaceCompanyCardsTable/index.tsx: Add the lastSynced column to columns:
{
    key: 'lastSynced',
    label: translate('workspace.companyCards.lastSynced'),
    sortable: true,
    styling: {
        containerStyles: [styles.mnw0],
    },
    dynamicSizing: {
        getContentToMeasure: (item) => (item.lastSyncedText ? [{text: item.lastSyncedText, fontSize: fontScale.text}] : []),
        shouldFitContent: true,
    },
},
  1. Sort Comparator in WorkspaceCompanyCardsTable.tsx: Handle null/undefined timestamps safely:
if (activeSorting.columnKey === 'lastSynced') {
    const aTime = a.lastScrapeTimestamp ? new Date(a.lastScrapeTimestamp).getTime() : 0;
    const bTime = b.lastScrapeTimestamp ? new Date(b.lastScrapeTimestamp).getTime() : 0;
    if (aTime === bTime) {
        return cardNameSortingResult;
    }
    return (aTime - bTime) * orderMultiplier;
}
  1. Row Rendering in WorkspaceCompanyCardsTableRow.tsx:
  • Wide table layout: Render the cell in line with existing columns:
{!shouldUseNarrowTableLayout && (
    <View
        style={[styles.flex1, styles.mnw0, styles.justifyContentCenter]}
        {...getCellAccessibilityProps(isTableSemanticsEnabled)}
    >
        <TextWithTooltip
            shouldShowTooltip
            numberOfLines={1}
            text={item.lastSyncedText ?? '-'}
            style={[styles.lh16, styles.optionDisplayName, styles.pre]}
        />
    </View>
)}
  • Narrow layout: In narrow mobile layouts where columns collapse into a card view, append Last synced: {item.lastSyncedText} as secondary text under memberCardSubtitle, keeping the experience fully responsive without overflowing mobile screen width.

Screenshots/Videos

Visual Mockup / Codebase Architecture Reference
  • Column architecture in table: https://github.com/Expensify/App/blob/main/src/components/Tables/WorkspaceCompanyCardsTable/index.tsx#L210-L280

  • Responsive cell layout in row: https://github.com/Expensify/App/blob/main/src/components/Tables/WorkspaceCompanyCardsTable/WorkspaceCompanyCardsTableRow.tsx#L190-L225

What alternative solutions did you consider?

Only showing the last synced timestamp in the settings sub-page, but displaying it directly in the table allows workspace admins to monitor sync health at a glance.

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~017a671f901fafe3a1

Hazem20wosis avatar Nov 04 '26 19:11 Hazem20wosis

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 04 '26 19:11 melvin-bot[bot]

@MelvinBot draft PR for testing

@mkhutornyi @MelvinBot let's title the column Last updated to match Classic.

trjExpensify avatar Nov 04 '26 19:11 trjExpensify

🤖 Web test steps verification results: ❌ fail

The provided web session remained blank, so all three browser checks are blocked, not demonstrated product failures.

Blank app page after the diagnostic pass
Step Status
Wide list: assigned-card sync timestamps and missing/unassigned placeholdersBlocked: Company cards was unreachable from the blank page.
Blank app page in the provided session
Blank app page after the diagnostic pass
❌
Narrow and medium layouts keep sync information readableNot verified; the app did not recover.
❌
Card details open and timestamp agreesNot verified; no card list or details was reachable.
❌

Draft PR created: Show last successful sync in Company cards, assigned to mkhutornyi. All 70 focused tests, typecheck, changed-file lint, explicit compiler checks, spelling, and Storybook passed. The full suite timed out; formatting and translation checks remain incomplete, with details in the PR. Please mark it as “Ready for review” when testing is complete.


view run · no recording available

MelvinBot avatar Nov 04 '26 19:11 MelvinBot

Use Last updated, keeping the last-successful-sync explanation. Show last successful sync in Company cards is assigned to mkhutornyi; I haven’t changed it.

I can only make code changes when directed by the PR author, an assignee, or an existing co-author. To have me implement this, the PR assignee or author should reply with a request tagging me.


view run

MelvinBot avatar Nov 04 '26 19:11 MelvinBot

Problem: Workspace admins on the Company Cards table cannot see when a company card feed was last synced, so a stale or broken feed looks identical to a healthy one until expenses stop appearing.

Root cause: WorkspaceCompanyCardsTable/index.tsx builds its columns (member, card, customCardName, exportAccount, actions) and its row data from Onyx cardList and cardFeeds, but never surfaces the sync timestamp the feeds already track (lastScrape / lastSuccessfulScrape on the feed/card settings). The data exists in Onyx; only the column is missing.

Fix:

  1. In WorkspaceCompanyCardsTable/index.tsx, when constructing WorkspaceCompanyCardTableItemData, extract lastScrape from assignedCard?.lastScrape ?? cardFeed?.lastScrape, format it with DateUtils.formatToLocalTime (falling back to - when absent), and carry both the display string and the raw timestamp on the row item.
  2. Add a lastSynced column (label under workspace.companyCards, e.g. lastSynced: 'Last synced' in src/languages/en.ts), sortable, with dynamic sizing measured from the formatted text like the other columns.
  3. In WorkspaceCompanyCardsTable.tsx, handle sorting on lastSynced by raw timestamp, treating missing timestamps as 0 so unsynced cards sort predictably instead of breaking the comparator.
  4. In WorkspaceCompanyCardsTableRow.tsx, render the cell in the wide table layout, and in the narrow layout append Last synced: <text> as secondary text under the member/card subtitle so the information is not lost on mobile.

Verification: A feed with a recent lastScrape shows a formatted local time; a never-synced feed shows -; sorting ascending/descending orders by actual sync time with unsynced rows grouped at one end; narrow layout still shows the value. Add unit tests for the row-data mapping (card-level timestamp preferred over feed-level, missing timestamp renders -) and for the sort comparator.

khizzcr7 avatar Nov 05 '26 00:11 khizzcr7

Proposal

Please re-state the problem that we are trying to solve in this issue.

On the workspace Company Cards page (Workspaces > [Workspace] > Company cards), the cards table currently displays Member, Card, Card name, and Export to, but does not display when each card was last synced ("Last synced"), even though that value is shown inside the individual card details page and exported in the CSV download.

What is the root cause of that problem?

In src/components/Tables/WorkspaceCompanyCardsTable/index.tsx, CompanyCardsTableColumnKey only defines 'member' | 'card' | 'customCardName' | 'exportTo', and src/components/Tables/WorkspaceCompanyCardsTable/WorkspaceCompanyCardsTableRow.tsx only renders cells for those four columns. Meanwhile, the logic to format a card's lastScrape / isLoadingLastUpdated status is duplicated inline in src/pages/workspace/companyCards/DynamicWorkspaceCompanyCardDetailsPage.tsx (lines 112–123) and src/components/Tables/WorkspaceCompanyCardsTable/WorkspaceCompanyCardsTableControls.tsx (lines 58–60) rather than shared via a utility and table column.

What changes do you think we should make in order to solve the problem?

  1. In src/libs/CardUtils.ts, add a shared helper getCompanyCardLastSyncedText(card: Card | undefined, translate: LocaleContextProps['translate']): string that returns:
    • translate('workspace.moreFeatures.companyCards.updating') when card?.isLoadingLastUpdated is true,
    • DateUtils.getFormattedTransportDate(DateUtils.getLocalDateFromDatetime(locale, card.lastScrape)) when card?.lastScrape is present, or
    • translate('workspace.moreFeatures.companyCards.neverUpdated') ("Never") when card?.lastScrape is empty.
  2. In src/languages/en.ts and src/languages/es.ts, add the column header translation workspace.moreFeatures.companyCards.lastSynced ("Last synced" / "Última sincronización").
  3. In src/components/Tables/WorkspaceCompanyCardsTable/index.tsx:
    • Add 'lastSynced' to CompanyCardsTableColumnKey right after 'customCardName'.
    • Include lastSynced: string on WorkspaceCompanyCardTableItem populated via getCompanyCardLastSyncedText(card, translate) and support sorting by card.lastScrape.
  4. In src/components/Tables/WorkspaceCompanyCardsTable/WorkspaceCompanyCardsTableRow.tsx, render the lastSynced column cell between customCardName and exportTo (and reuse getCompanyCardLastSyncedText in WorkspaceCompanyCardsTableControls.tsx and DynamicWorkspaceCompanyCardDetailsPage.tsx).

What alternative solutions did you explore? (Optional)

We considered hiding the "Last synced" column on commercial/CSV feeds where lastScrape is not populated, but showing "Never" (matching the CSV export and card details page) keeps the table columns consistent across feeds.

jeffrey-graham avatar Nov 07 '26 04:11 jeffrey-graham

📣 @jeffrey-graham! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

melvin-bot[bot] avatar Nov 07 '26 04:11 melvin-bot[bot]

📣 @ronanchnlps-bit! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

melvin-bot[bot] avatar Nov 07 '26 10:11 melvin-bot[bot]

Proposal

Please re-state the problem that we are trying to solve in this issue.

Workspace admins cannot see when company cards were last updated without opening each individual card details view. A "Last synced" column needs to be displayed in the workspace Company cards list.

What is the root cause of that problem?

In WorkspaceCompanyCardsPage.tsx / CompanyCardsTable.tsx: The table header and rows render cardholder name, card number, and feed name, but do not include a column mapping the lastScrape timestamp stored in the card feed metadata.

What changes do you think we should make in order to solve the problem?

  1. In WorkspaceCompanyCardsPage.tsx / CompanyCardsTable.tsx:
    • Add a "Last synced" column header to the Company cards table.
    • For each card row, extract and format card.lastScrape using DateUtils.toLocalTime or relative time format (e.g., "X hours ago" or date string).
    • Display a fallback label (such as "Never" or "-") when lastScrape is absent or unassigned.
  2. Ensure responsive column hiding on compact mobile layouts to maintain readability.

What alternative solutions did you explore? (Optional)

Showing the sync timestamp as subtitle text under the card name, but a dedicated table column provides better alignment and sortability for administrators.

TassioSales avatar Nov 08 '26 00:11 TassioSales

🚨 Edited by proposal-police: This proposal was edited at 2026-11-10 03:25:05 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

Admins have to open each company card to see when it last synced. The Company cards table should show that time directly.

What is the root cause of that problem?

This is a new feature. lastScrape is already on every assigned card in the table, since the rows come from the same useCardsList(feedName) the details page reads (useCompanyCards.ts#L171-L177). Only the details page renders it (DynamicWorkspaceCompanyCardDetailsPage.tsx#L147-L149, #L215). The table has no column for it (index.tsx#L210-L279).

What changes do you think we should make in order to solve the problem?

Add a Last updated column (title per https://github.com/Expensify/App/issues/105949#issuecomment-6640194533) showing the Spend date abbreviation (per https://github.com/Expensify/App/pull/105955#issuecomment-6640409070), with the exact details page "Last updated" value in the tooltip, so the two screens never disagree.

  1. Value. In cardsData (index.tsx#L300) add lastUpdatedText and lastUpdatedTooltip, with the same states as the details page and the date abbreviated like the local time zone branch of Spend's DateCell (DateCell.tsx#L43-L46), since lastScrape is a UTC instant:
    let lastUpdatedText: string | undefined;
    let lastUpdatedTooltip: string | undefined;
    if (assignedCard?.isLoadingLastUpdated) {
        lastUpdatedText = translate('workspace.moreFeatures.companyCards.updating');
    } else if (assignedCard?.lastScrape) {
        const localDate = getLocalDateFromDatetime(assignedCard.lastScrape);
        const isPastYear = localDate.getFullYear() !== getLocalDateFromDatetime().getFullYear();
        lastUpdatedText = format(localDate, isPastYear ? CONST.DATE.MONTH_DAY_YEAR_ABBR_FORMAT : CONST.DATE.MONTH_DAY_ABBR_FORMAT, {locale: dateFnsLocale});
        lastUpdatedTooltip = format(localDate, CONST.DATE.FNS_DATE_TIME_FORMAT_STRING);
    } else if (assignedCard) {
        lastUpdatedText = translate('workspace.moreFeatures.companyCards.neverUpdated');
    }
    
    • Synced card: Nov 4 (or Mar 1, 2025 for a past year) in the admin's time zone, so the day matches the details page.
    • Assigned but never synced: Never.
    • While "Update card" runs: Updating....
    • Unassigned card: empty cell. There is no card, so no sync history.
  2. Column. Add lastUpdated to CompanyCardsTableColumnKey and a column after Export account (#L259), labeled with the existing workspace.moreFeatures.companyCards.lastUpdated. styles.mnw0 plus dynamicSizing with shouldFitContent, since the value has a fixed length.
  3. Cell. In WorkspaceCompanyCardsTableRow, render the value after the Export account cell (#L204-L216) under the same !shouldUseNarrowTableLayout guard, and add it to the row accessibilityLabel (#L128).
  4. Tooltip. When the cell shows a date, wrap it in a Tooltip with just the full timestamp, e.g. 2026-11-04 18:54:12, exactly as the details page and CSV export show it (per https://github.com/Expensify/App/issues/105949#issuecomment-6753609231). No new translation.
  5. Sorting. Make the column sortable. lastScrape is a UTC yyyy-MM-dd HH:mm:ss string, so string order is time order. Never synced cards sort as oldest, ties fall back to card name like Export account (#L386-L394). The assigned/unassigned grouping stays.
  6. Compact layouts. On narrow and medium widths the column is hidden like Card, Card name and Export account, so rows stay two lines. The value remains on the card details page.
  7. (Optional) Malformed timestamp. getLocalDateFromDatetime returns an Invalid Date for a malformed string, and format then throws RangeError. The server always sends yyyy-MM-dd HH:mm:ss, and the details page and CSV export make the same unguarded call today. If we want a guard anyway, check isValid before formatting and fall back to Never, so a bad value can't break the table.

Test branch: https://github.com/Expensify/App/compare/main...samarroy84:App:fix-105949?expand=1

What alternative solutions did you explore? (Optional)

  • Full yyyy-MM-dd HH:mm:ss in the cell. Matches the details page without hovering, but it isn't the Spend abbreviation and makes the column much wider. The tooltip keeps the exact value.
  • Keep the old date while "Update card" runs. Avoids a flicker but disagrees with the details page, which shows Updating....
  • Third subtitle line on narrow layouts. Makes every mobile row taller for a value admins mostly check on desktop.
  • N/A for unassigned cards. Adds noise to every unassigned row. An empty cell already says there is nothing to sync.

samarroy84 avatar Nov 08 '26 16:11 samarroy84

🚨 Edited by proposal-police: This proposal was edited at 2026-11-09 06:22:56 UTC.

Proposal

What is the root cause of that problem?

New feature. lastScrape is already on every assigned row (assignedCard), but nothing in the table reads it: no column key, no row field, no cell https://github.com/Expensify/App/blob/5ebbde7d7cca4d372921e1ce0350b6962cf0cced/src/components/Tables/WorkspaceCompanyCardsTable/index.tsx#L56 https://github.com/Expensify/App/blob/5ebbde7d7cca4d372921e1ce0350b6962cf0cced/src/components/Tables/WorkspaceCompanyCardsTable/index.tsx#L300-L313

The tricky part is not adding a cell, it's that the value has to follow two display rules that the app currently implements in different places, and the "obvious" reuse of either one gets it wrong.

1. The cell must use the Spend date abbreviation (requested here), but Spend's default date path is wrong for lastScrape. DateCell has two branches. The default one formats the string as a calendar date in UTC (fine for a transaction date), and only the shouldUseLocalTimeZone branch converts an instant to the user's timezone: https://github.com/Expensify/App/blob/5ebbde7d7cca4d372921e1ce0350b6962cf0cced/src/components/Search/SearchList/ListItem/DateCell.tsx#L42-L53

lastScrape is a UTC DB datetime (an instant), and the details page and CSV both show it in the admin's timezone: https://github.com/Expensify/App/blob/5ebbde7d7cca4d372921e1ce0350b6962cf0cced/src/pages/workspace/companyCards/DynamicWorkspaceCompanyCardDetailsPage.tsx#L148-L150 https://github.com/Expensify/App/blob/5ebbde7d7cca4d372921e1ce0350b6962cf0cced/src/components/Tables/WorkspaceCompanyCardsTable/WorkspaceCompanyCardsTableControls.tsx#L91

I checked it with the real date-fns calls: for lastScrape = "2026-11-05 02:30:00" and an admin in America/Los_Angeles, the default Spend path prints Nov 5, while the details page prints 2026-11-04 18:30:00. So the row would say the card synced a day later than its own details page. The cell has to use the local timezone branch, and the full details page string goes in the tooltip so the two screens still match exactly.

2. The cell has to show "Updating..." too, not only the date. "Update card" (and the reconnect flow in useUpdateFeedBrokenConnection) merges isLoadingLastUpdated + pendingFields.lastScrape into the same cards_ key the table reads, and keeps the old lastScrape until the server answers. On failure it only writes errorFields.lastScrape, so lastScrape really is the last successful sync: https://github.com/Expensify/App/blob/5ebbde7d7cca4d372921e1ce0350b6962cf0cced/src/libs/actions/CompanyCards.ts#L650-L729

The details page reads that flag before the date, so a cell built from lastScrape alone shows a stale date while the RHP over it says "Updating...": https://github.com/Expensify/App/blob/5ebbde7d7cca4d372921e1ce0350b6962cf0cced/src/pages/workspace/companyCards/DynamicWorkspaceCompanyCardDetailsPage.tsx#L241-L243

3. CSV import feeds have nothing to sync. Their cards come from a spreadsheet upload, not a bank connection. The Wallet already knows this and never shows "Last synced" for them: https://github.com/Expensify/App/blob/5ebbde7d7cca4d372921e1ce0350b6962cf0cced/src/pages/settings/Wallet/PaymentMethodList.tsx#L309 https://github.com/Expensify/App/blob/5ebbde7d7cca4d372921e1ce0350b6962cf0cced/src/pages/settings/Wallet/PaymentMethodList.tsx#L371

A column without that rule would print "Never" on every row of a CSV feed, which reads as "all your cards are broken" and makes sorting meaningless.

4. The current sort can't put stale cards first. compareItems pins unassigned rows above assigned ones in ascending order and has no date branch, so "oldest first" would open with a page of unassigned rows, which have no date at all: https://github.com/Expensify/App/blob/5ebbde7d7cca4d372921e1ce0350b6962cf0cced/src/components/Tables/WorkspaceCompanyCardsTable/index.tsx#L353-L393

What changes do you think we should make in order to solve the problem?

1. One formatter, built on the Spend logic. Move the local timezone branch of DateCell into a small DateUtils function and use it from DateCell too, so the cell is literally the Spend abbreviation and not a copy of it:

function formatLocalDateAbbreviated(localDate: Date, localNow: Date, dateFnsLocale?: DateFnsLocale) {
    const isPastYear = localDate.getFullYear() !== localNow.getFullYear();
    return format(localDate, isPastYear ? CONST.DATE.MONTH_DAY_YEAR_ABBR_FORMAT : CONST.DATE.MONTH_DAY_ABBR_FORMAT, {locale: dateFnsLocale});
}

Then one helper in CardUtils, next to parseCardLastScrape (which already parses the DB datetime as UTC, accepts ISO and returns undefined for empty or invalid values): https://github.com/Expensify/App/blob/5ebbde7d7cca4d372921e1ce0350b6962cf0cced/src/libs/CardUtils.ts#L1800-L1818

function getCardLastUpdated(card, translate, getLocalDateFromDatetime, dateFnsLocale) {
    if (card.isLoadingLastUpdated) {
        return {text: translate('workspace.moreFeatures.companyCards.updating'), timestamp: parseCardLastScrape(card)?.getTime()};
    }
    const date = parseCardLastScrape(card);
    if (!date) {
        return {text: translate('workspace.moreFeatures.companyCards.neverUpdated')};
    }
    const localDate = getLocalDateFromDatetime(card.lastScrape);
    return {
        text: formatLocalDateAbbreviated(localDate, getLocalDateFromDatetime(), dateFnsLocale),
        fullText: format(localDate, CONST.DATE.FNS_DATE_TIME_FORMAT_STRING),
        timestamp: date.getTime(),
    };
}

fullText is the exact details page string. The details page uses fullText from this helper instead of its inline copy, so there's one source for both screens. As a bonus, an invalid value now falls back to "Never" instead of format() throwing RangeError, which in the table would take down the whole list, not one RHP.

2. Column. Add lastUpdated to CompanyCardsTableColumnKey and a sortable column after Card name, labelled with the existing workspace.moreFeatures.companyCards.lastUpdated ("Last updated", same as Classic). styles.mnw0 + dynamicSizing with shouldFitContent, measured from text. Don't add the column when isCSVUploadFeed(feedName), the same rule the Wallet applies to these cards: https://github.com/Expensify/App/blob/5ebbde7d7cca4d372921e1ce0350b6962cf0cced/src/libs/CardUtils.ts#L931-L937

3. Row data. In cardsData, call the helper only when there is an assignedCard, and add lastUpdated (text, fullText, timestamp) to the row item. Unassigned rows get nothing.

4. Cell. In WorkspaceCompanyCardsTableRow, under the same !shouldUseNarrowTableLayout guard as Card / Card name / Export account: https://github.com/Expensify/App/blob/5ebbde7d7cca4d372921e1ce0350b6962cf0cced/src/components/Tables/WorkspaceCompanyCardsTable/WorkspaceCompanyCardsTableRow.tsx#L175-L216

  • synced: Nov 4 (or Nov 4, 2025 for a past year), wrapped in Tooltip with "Last successful sync: 2026-11-04 18:30:00" (one new string lastSuccessfulSync)
  • assigned, never synced: "Never"
  • update running: "Updating..."
  • unassigned: empty cell, no "N/A"

Add text to the row accessibilityLabel https://github.com/Expensify/App/blob/5ebbde7d7cca4d372921e1ce0350b6962cf0cced/src/components/Tables/WorkspaceCompanyCardsTable/WorkspaceCompanyCardsTableRow.tsx#L128

5. Narrow and medium layouts. No change. The cell is hidden there like the other secondary columns, so rows keep their two lines. The value stays one tap away on the details page.

6. Sorting. For lastUpdated only, keep unassigned rows after assigned rows in both directions (checked before the existing grouping), then compare timestamp: "Never" counts as oldest, ties fall back to card name like the exportAccount branch. An "Updating..." row keeps its old timestamp, so it doesn't jump while the update runs. Ascending then puts never synced and stalest cards on top, which is why admins open each card today.

Tests (Given/When/Then)

  • helper: Los Angeles admin + 2026-11-05 02:30:00 gives Nov 4 and the details page fullText; past year shows the year; ISO value; empty and invalid give "Never"; isLoadingLastUpdated gives "Updating..." and keeps the timestamp
  • DateCell local timezone output unchanged after the move
  • compareItems: ascending gives Never, then oldest, then unassigned; descending keeps unassigned last; ties by card name
  • row: cell on wide, nothing on narrow, empty for unassigned; column absent for a CSV feed

What alternative solutions did you explore? (Optional)

  • Pass lastScrape to DateCell as is. Least code, but DateCell is an editable Search cell and its default branch formats in UTC, which gives the wrong day above. It also has no "Updating..." or "Never" state.
  • Full yyyy-MM-dd HH:mm:ss in the cell to match the details page 1:1. Matches without a tooltip, but it's not the Spend abbreviation that was asked for and it widens the column a lot. The tooltip gives the same exact value.
  • Show "Never" for CSV feeds instead of hiding the column. Keeps every feed's table the same shape, but every row would say "Never" for cards that can't sync by design, and it goes against what the Wallet already does for the same cards.
  • Relative time ("2 days ago"). Easy to scan, but it goes stale while the page is open and matches neither the Spend dates nor the CSV.

David-2002065 avatar Nov 08 '26 16:11 David-2002065

🚨 Edited by proposal-police: This proposal was edited at 2026-11-08 16:17:31 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

On the workspace Company cards page, admins have to open each card's details page to see when it last synced. We want a "Last synced" column in the Company cards list that shows each card's last successful sync time (from the existing lastScrape value), handles cards with no timestamp and unassigned cards, and stays readable in compact layouts.

What is the root cause of that problem?

This is a new feature. The Company cards table only defines the Member, Card, Card name, optional Export account and actions columns:

https://github.com/Expensify/App/blob/ce539ca4cded9df7a22551846b4cb7585f635de4/src/components/Tables/WorkspaceCompanyCardsTable/index.tsx#L210-L279

and the row component only renders cells for those columns:

https://github.com/Expensify/App/blob/ce539ca4cded9df7a22551846b4cb7585f635de4/src/components/Tables/WorkspaceCompanyCardsTable/WorkspaceCompanyCardsTableRow.tsx#L204-L217

The lastScrape timestamp is already on each assigned card (assignedCard is passed to every row), but it is only formatted and shown on the card details page:

https://github.com/Expensify/App/blob/ce539ca4cded9df7a22551846b4cb7585f635de4/src/pages/workspace/companyCards/DynamicWorkspaceCompanyCardDetailsPage.tsx#L147-L149

and in the CSV export:

https://github.com/Expensify/App/blob/ce539ca4cded9df7a22551846b4cb7585f635de4/src/components/Tables/WorkspaceCompanyCardsTable/WorkspaceCompanyCardsTableControls.tsx#L90

What changes do you think we should make in order to solve the problem?

  1. Compute the value once per row. In the cardsData mapping, add a lastSyncedDate field (the parsed date, used for sorting) and a lastSynced display string to each row item:

https://github.com/Expensify/App/blob/ce539ca4cded9df7a22551846b4cb7585f635de4/src/components/Tables/WorkspaceCompanyCardsTable/index.tsx#L300-L329

  • Parse with the existing parseCardLastScrape helper in CardUtils (exported for this), which already treats the DB datetime as UTC and falls back to ISO 8601 for other formats:

https://github.com/Expensify/App/blob/ce539ca4cded9df7a22551846b4cb7585f635de4/src/libs/CardUtils.ts#L1809-L1818

  • Format it for display in the user's timezone the same way the details page and CSV export do (getLocalDateFromDatetime + CONST.DATE.FNS_DATE_TIME_FORMAT_STRING), so all three places show the same value.
  • Unassigned cards: leave the value empty. They have no assignedCard and nothing to sync yet, so the cell stays blank, like the Card name and Export account cells do for unassigned rows.
  • Assigned card with no lastScrape: show the existing workspace.moreFeatures.companyCards.neverUpdated copy ("Never"), the same fallback the details page uses.
  • Sync in progress (assignedCard.isLoadingLastUpdated, the same flag the details page reads): show the existing updating copy so the column matches the details page while a manual update runs.
  1. Add the column. Add a sortable lastSynced entry to CompanyCardsTableColumnKey and to columns, placed before the Export account column. Its label is a new workspace.moreFeatures.companyCards.lastSynced translation ("Last synced") in every language file. Use dynamicSizing with getContentToMeasure on the formatted string, with shouldFitContent (the date string has a fixed width), like the Card column does.

  2. Render the cell. In WorkspaceCompanyCardsTableRow, add a cell before the Export account cell, rendered only when !shouldUseNarrowTableLayout (same as the other secondary columns). It shows item.lastSynced in single-line text with the same styles as the Card cell. To make clear it means the last successful sync, wrap the value in the existing Tooltip component with a new lastSuccessfulSync string, e.g. "Last successful sync: " (no tooltip while an update is running). The table header has no tooltip support today, so the hint goes on the cell instead. Also add the value to the row's accessibilityLabel list:

https://github.com/Expensify/App/blob/ce539ca4cded9df7a22551846b4cb7585f635de4/src/components/Tables/WorkspaceCompanyCardsTable/WorkspaceCompanyCardsTableRow.tsx#L128

  1. Compact layouts. On narrow and medium layouts the table collapses each row into the Member cell, so a new column would not show. Instead, add the sync time to the Member cell's subtitle for assigned cards, after the card details. Today that subtitle is <masked card> • <card name>; it becomes <masked card> • <card name> • <Last synced: date>. The subtitle is already a one-line TextWithTooltip, so long values get truncated with the full text in the tooltip, and the row keeps its height. Unassigned cards keep their current subtitle.

https://github.com/Expensify/App/blob/ce539ca4cded9df7a22551846b4cb7585f635de4/src/components/Tables/WorkspaceCompanyCardsTable/WorkspaceCompanyCardsTableRow.tsx#L99

  1. Sorting. Add a lastSynced branch to compareItems that compares lastSyncedDate timestamps. Cards that never synced sort as the oldest, and ties fall back to the card name, as the Export account branch does. Unassigned cards are already grouped before this branch is reached, so they need no special case:

https://github.com/Expensify/App/blob/ce539ca4cded9df7a22551846b4cb7585f635de4/src/components/Tables/WorkspaceCompanyCardsTable/index.tsx#L353-L394

  1. Unify the copy. Rename the CSV export header from lastUpdated to the new lastSynced label, so the export and the column use the same name. The CSV keeps its own value, so a card that never synced stays blank in the file instead of getting the "Never" or "Updating..." display copy.

Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/105949-company-cards-last-synced?expand=1

What alternative solutions did you explore? (Optional)

  • Relative time ("2 hours ago") instead of an absolute timestamp. It is easier to scan, but it goes stale unless the list re-renders on a timer, and it doesn't match the absolute time on the details page and in the CSV. We could add it later as a tooltip on the absolute value.
  • Always show the column, even on narrow layouts. Rejected: the narrow table renders a single Member cell per row, so an extra column would either be hidden or crowd the avatar and name. Putting the time in the subtitle keeps the information without changing the row layout.

wildan-m avatar Nov 08 '26 16:11 wildan-m

Proposal

Please re-state the problem that we are trying to solve in this issue.

On the workspace Company cards table, admins can only see when a card last synced by opening each card's details page. We want a "Last synced" column that shows the card's existing lastScrape value right in the list.

What is the root cause of that problem?

This is a new feature, so nothing is broken. The value already exists, but only one screen renders it:

  1. Each assigned card's Onyx object already carries lastScrape, the last successful sync. Failed attempts are tracked separately, as the doc comment on isLastScrapePastDismissThreshold notes.
  2. Only the card details page renders it ("Last updated: ..."): DynamicWorkspaceCompanyCardDetailsPage.tsx#L147-L149, with an "Updating..." state while a sync runs, at #L215.
  3. The table's column list stops at member / card / card name / export account / actions: WorkspaceCompanyCardsTable/index.tsx#L210-L279. The row builder never reads assignedCard.lastScrape (#L281-L331), and the row has no cell for it (WorkspaceCompanyCardsTableRow.tsx#L204-L216).
  4. The table's CSV export already writes the same value as "Last updated" (WorkspaceCompanyCardsTableControls.tsx#L90), so the on-screen table is the only place it is missing.

Every path the new column has to handle:

  • Unassigned card rows have no assignedCard, so they have no lastScrape and no details page (#L284-L285).
  • Assigned but never synced: lastScrape is empty.
  • Sync in flight: "Update" on the details page sets isLoadingLastUpdated and pendingFields.lastScrape (CompanyCards.ts#L650-L700). The table already reads that pending flag for errors (#L296).
  • Narrow and medium widths use the compact layout (shouldUseNarrowTableLayout, #L197). There, every column except member is hidden and the row is just avatar, name and subtitle.
  • Sorting: compareItems has one branch per column key.
  • Two date formats: lastScrape is usually a UTC DB datetime with no offset. Some values are already ISO. parseCardLastScrape handles both, but it is not exported.

What changes do you think we should make in order to solve the problem?

I would add the column the same way PR #100738 added the "Export account" column to this table:

  1. Row data (index.tsx, in the cardsData map): add lastSyncedText:
    • unassigned → undefined (empty cell);
    • assignedCard.isLoadingLastUpdated → the existing workspace.moreFeatures.companyCards.updating ("Updating...");
    • lastScrape present → format(getLocalDateFromDatetime(lastScrape), CONST.DATE.FNS_DATE_TIME_FORMAT_STRING). This is the exact string the details page and the CSV show, so the three always agree;
    • otherwise → a new neverSynced: 'Never' key. Also add lastSyncedTimestamp = parseCardLastScrape(assignedCard)?.getTime() for sorting (export parseCardLastScrape from CardUtils).
  2. Column: add a sortable lastSynced entry before the export account column, labelled with a new lastSynced: 'Last synced' key. It uses dynamicSizing: {getContentToMeasure: (item) => ..., shouldFitContent: true}, so the track is only as wide as a date and doesn't squeeze the free-text columns.
  3. Row cell (WorkspaceCompanyCardsTableRow.tsx): render it like the export account cell, inside !shouldUseNarrowTableLayout. Wrap the text in the existing Tooltip with a new lastSyncedTooltip: 'Last successful sync' string. Add the value to the row's accessibilityLabel (#L128). This is how we make clear the value is the last successful sync without making the header longer.
  4. Sorting: add the branch below. "Never" sorts oldest, and ties fall back to the card name, like the exportAccount branch does.
if (activeSorting.columnKey === 'lastSynced') {
    const diff = (a.lastSyncedTimestamp ?? 0) - (b.lastSyncedTimestamp ?? 0);
    return (diff !== 0 ? Math.sign(diff) : cardNameComparison) * orderMultiplier;
}

New strings go in en.ts next to lastUpdated; the other locales are generated.

Regression safety: only the workspace Company cards table changes. The Expensify Cards table, the details page and the CSV export are untouched. The compact layout looks exactly as it does today, because the column is hidden there.

Why the obvious one-liner is not enough: rendering assignedCard.lastScrape straight into a new cell shows the raw DB string. That string is UTC with no offset, so it is off from the details page by the admin's timezone offset. It also shows a blank both for "never synced" and for unassigned rows, so the two can't be told apart, and it sorts as a string. The issue asks for missing timestamps to be handled, so the local-time conversion, the "Never" state and the timestamp sort are all needed.

Every requirement in the issue is covered:

  • existing lastScrape: ✅
  • last successful sync made clear (tooltip and a11y label): ✅
  • missing timestamps ("Never") and unassigned rows (empty): ✅
  • compact layouts (hidden when narrow, fit-content when wide): ✅

What alternative solutions did you explore? (Optional)

  • Relative text ("Synced 3 hours ago"), reusing walletPage.cardLastSynced the way PaymentMethodList.tsx#L370-L374 does. It is shorter, but it goes stale while the page stays open. It also no longer matches the details page or the CSV, so the same card would show two different values. Easy to switch if Design prefers it.
  • Showing it in the narrow subtitle (card • name • date): this crowds the only secondary line on mobile, which goes against "keep compact layouts readable". The date is one tap away on the details page there.
  • Header tooltip: TableColumn has no header-tooltip prop (Table/types.ts#L86-L104). Adding one changes the shared Table for every table in the app. The tooltip on the cell gives the same clarity with a smaller blast radius.

ahmdshrif avatar Nov 08 '26 16:11 ahmdshrif