You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-07-23] [$250] Workspace setting- Company cards page loads each time opening it #93404
Version Number: 9.4.6-0 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: EDGE https://github.com/Expensify/Expensify/issues/608024 Email or phone of affected tester (no customers): undefined Issue reported by: Applause Internal Team
Every time the Company cards page mounts, it unconditionally re-fetches the feed and re-shows the skeleton — even when the cards are already cached in Onyx.
The page has a useEffect that fires the feed fetch on every mount with no "already loaded" guard:
Contrast this with the sibling effect right above it (L70-76), which does guard with hasFeedsLoaded and skips the fetch when feeds already exist. The feed-level fetch has no equivalent guard.
loadPolicyCompanyCardsFeed calls openPolicyCompanyCardsFeed, whose optimisticData unconditionally sets cardFeedsStatus[feed].isLoading = true. The table reads exactly that flag and renders the skeleton:
The lone guard inside loadPolicyCompanyCardsFeed (L79) checks the page's local isLoading, which is itself based on isLoadingOnyxValue(cardListMetadata) (L66). On remount, useOnyx subscriptions transition through status: 'loading' for a tick even when the value is cached, so the guard races: it can be true on the first render and false on the next, at which point the effect re-fires the API + the optimistic isLoading: true. Result: the skeleton flashes on every navigation back to the page.
Why it reproduces on every navigation
Navigate away → page unmounts → Onyx subscriptions torn down.
Navigate back → page remounts; useOnyx metadata is briefly 'loading'.
The unguarded effect fires openPolicyCompanyCardsFeed; its optimistic merge sets cardFeedsStatus[feed].isLoading = true.
WorkspaceCompanyCardsTable reads areWorkspaceCardFeedsLoading and renders the skeleton.
Server responds; successData flips isLoading: false; cards reappear.
Note: this is a long-standing behavior (reported on v9.4.6-0), not specific to the recent refactor in PR #93202 — that PR rewrote this file but the unguarded-fetch pattern persists.
What changes do you think we should make in order to solve the problem?
Add an "already loaded" guard to the feed fetch, mirroring the existing hasFeedsLoaded guard on the sibling effect:
In loadPolicyCompanyCardsFeed (or its useEffect), skip the call when the selected feed's cards are already present in Onyx (e.g. cardsList/companyCardEntries is non-empty, or cardListMetadata.status === 'loaded'). This prevents the redundant OpenPolicyCompanyCardsFeed call on remount.
Optionally, also make openPolicyCompanyCardsFeed's optimistic isLoading: true write conditional on there being no cached cards, so the skeleton only shows on the genuine first load.
This keeps the first-load behavior intact while eliminating the skeleton flash on subsequent visits.
What alternative solutions did you explore? (Optional)
Gate the skeleton render in WorkspaceCompanyCardsTable so it never shows while cached cards exist (treat the refetch as a background refresh). This addresses the symptom but still issues a redundant API call on every mount, so the guard on the fetch is preferred.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/93404) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
Please re-state the problem that we are trying to solve in this issue.
On Web, when a user navigates from a workspace's Company cards page to another workspace page (e.g. Categories) and back, the Company cards page re-fetches the feed and flashes the loading skeleton on every revisit, instead of rendering the already-cached cards immediately.
What is the root cause of that problem?
In src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsx, the effect at lines 86–88 calls loadPolicyCompanyCardsFeed() on every mount without checking whether the feed's card list is already loaded. The internal guards in loadPolicyCompanyCardsFeed (lines 78–84) only short-circuit on isLoading/!bankName/isFeedPending/isOffline — none of which are true on a revisit when the cards are already cached — so it calls openPolicyCompanyCardsFeed, which optimistically writes cardFeedsStatus[feed].isLoading: true (src/libs/actions/CompanyCards.ts lines 966–981). That flips the table into its skeleton state until the network response returns. The sibling effect for loadPolicyCompanyCardsPage (lines 70–76) avoids the same issue with a hasFeedsLoaded guard; the feed effect has no equivalent.
What changes do you think we should make in order to solve the problem?
src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsx lines 86–88: gate the effect with a "cards already loaded for this feed" check, mirroring the hasFeedsLoaded pattern used at line 71. Skip the call when cardsList for the current feedName is already present and non-empty (i.e. derive hasCardsLoaded from companyCards.cardList/assignedCards or check cardListMetadata.status === 'loaded' together with a non-undefined value).
src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsx line 84: drop unneeded reactive deps from loadPolicyCompanyCardsFeed (e.g. isLoading) so the callback identity is stable across re-renders within the same mount, preventing redundant effect re-runs even if the guard above is bypassed.
Keep the existing manual onReloadFeed path (passed to WorkspaceCompanyCardsTable line 117) unchanged so users can still explicitly refresh.
What alternative solutions did you explore? (Optional)
Tracking a "fetched once per (policyID, feedName)" ref to suppress re-fetch on remount — rejected because Onyx already holds the cached cards; a data-driven guard (option 1) is simpler and survives provider remounts.
When you leave the page (to Categories) and come back, the component remounts and the useCardFeeds Onyx subscription re-hydrates from cache. On the first render allCardFeeds is still undefined (status loading), so hasFeedsLoaded is false and the effect fires openPolicyCompanyCardsPage again — even though the data is already cached and about to arrive. That call optimistically sets the domain-member isLoading: true flag, which the table reads as areWorkspaceCardFeedsLoading and turns into the skeleton:
So the chain is: remount → feeds collection briefly loading from cache → hasFeedsLoaded false → guard ignores the loading state → spurious OpenPolicyCompanyCardsPage refetch → isLoading flag flips on while cards haven't rebuilt yet → full skeleton flashes on every visit.
What changes do you think we should make in order to solve the problem?
Don't treat "feeds collection is still hydrating" as "feeds not loaded". useCompanyCards already exposes isInitiallyLoadingFeeds (= isLoadingOnyxValue(allCardFeedsMetadata)):
if (isOffline || hasFeedsLoaded || isInitiallyLoadingFeeds) {
return;
}
loadPolicyCompanyCardsPage();
(add isInitiallyLoadingFeeds to the dependency array). A true first-time load still works: once isInitiallyLoadingFeeds resolves to false with no feeds, the fetch fires as before — but a revisit with cached feeds no longer refetches, so the skeleton stops flashing.
What alternative solutions did you explore? (Optional)
Cache the "already fetched this policy" decision in a ref/Onyx flag so the fetch only runs once per session. This avoids the hydration race too, but it adds extra state to manage and still re-runs after a genuine cache eviction; gating on the existing loading metadata is the smaller, more direct fix.
changed the title [-]Workspace setting- Company cards page loads each time opening it[/-][+][$250] Workspace setting- Company cards page loads each time opening it[/+]on Jun 12, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-06-15 07:03:30 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On the Workspace Company cards page, the card list re-runs its loading state (skeleton) every time you navigate away to another workspace page (e.g. Categories) and come back, even though the data is already cached. Re-opening the page should not re-trigger a load.
What is the root cause of that problem?
WorkspaceCompanyCardsPage has two data-loading effects, each of which drives a skeleton via an optimistic isLoading: true, and they fail to skip on a revisit for two distinct reasons.
1. The feed-cards effect has no "already loaded" guard. It calls loadPolicyCompanyCardsFeed() unconditionally on every mount:
For a workspace with zero feeds, allCardFeeds stays empty forever, so hasFeedsLoaded is permanently false. Every revisit re-fires openPolicyCompanyCardsPage, which optimistically re-sets the domain-member root isLoading: true → the table reads it as areWorkspaceCardFeedsLoading → isLoadingPage → skeleton. The feed-level guard can't help here because there is no selectedFeed.
(Note: for a workspace with feeds, the page effect is already safe — allCardFeeds is a cached SHARED_NVP_PRIVATE_DOMAIN_MEMBER collection, so useOnyx returns status: 'loaded' synchronously on the first render after remount and hasFeedsLoaded is true on render #1. So the page-level fetch only needs the no-feed fix, while the feed-level fetch needs the missing guard.)
What changes do you think we should make in order to solve the problem?
Guard both effects on a resolved Onyx status (isLoading === false) — the signal that persists in SHARED_NVP_PRIVATE_DOMAIN_MEMBER across the remount — instead of on value presence. A genuine first load (status === undefined) still fires; a revisit refetches neither.
1. Page-load effect — covers the no-feed workspace:
isInitiallyLoadingFeeds gates the cold-start hydration window: while allCardFeeds is still hydrating, workspaceCardFeedsStatus is empty, so the resolved-status check would read undefined === false and fire a wasteful fetch before the persisted status is even available. It's status === 'loading' (set only on isFirstConnection && hasPendingMergeForKey), guaranteed to flip to false once the initial read settles — so it can never block the genuine first load.
2. Feed-load effect — covers the cached-feed revisit, on === false (not just truthy) so an interrupted {isLoading: true} self-heals instead of stranding the skeleton:
Cold-start hydration: while feeds are still hydrating (isInitiallyLoadingFeeds), the page effect defers instead of reading the not-yet-hydrated root status; once settled it skips (resolved) or fires the first load (never fetched).
First-ever load: both statuses are undefined → both fetches still fire once.
Feed switching: changes bankName/selectedFeed; the new feed's status is undefined → it loads.
Interrupted fetch ({isLoading: true}): falls through and self-heals instead of stranding the page.
Manual reload & offline: untouched — the guards live in the effects, so onReloadPage/onReloadFeed and the existing offline/pending/bankName guards inside the callbacks still apply.
All platforms: root cause is platform-agnostic React/Onyx logic, so the fix covers Web, mWeb, iOS and Android.
What alternative solutions did you explore? (Optional)
Make the table ignore the optimistic isLoading when cards already exist — papers over the symptom (the skeleton) while still firing redundant OPEN_POLICY_COMPANY_CARDS_PAGE / OPEN_POLICY_COMPANY_CARDS_FEED requests on every open.
Use a useRef "already fetched" flag — a ref resets on unmount, so it doesn't survive the revisit; the Onyx-backed resolved status is the only signal that persists across the remount.
Guard on cardList / card-entry presence — regresses valid feeds (and workspaces) that resolved with zero cards, since presence never becomes truthy for them.
For a workspace with no feeds there are no cached cards to suppress the loader (hasCards is false), so the skeleton flashes on every revisit. Compare this with Categories/Tags: they also fetch on every visit, but gate their skeleton on a durable per-policy data key that a refetch never resets, so it never re-flashes:
The company cards skeleton instead keys off the transient optimistic flag — and that flag isn't durable either: the backend re-sends the sharedNVP_private_domain_member NVP without it on navigation, so any "loaded once" marker stored there is wiped between visits (I confirmed this at runtime — the flag read false on one mount and undefined on the very next visit).
What changes do you think we should make in order to solve the problem?
Keep fetching on every visit (consistent with Categories/Tags), and stop the skeleton from being driven by the optimistic flag once we've already resolved that the workspace has no feeds.
In WorkspaceCompanyCardsTable, add !isNoFeed to isLoadingPage:
isNoFeed is derived from the feeds collection's Onyx metadata, not the optimistic flag, so it stays true through the background refetch — the company-cards analog of Categories' durable policyCategories:
Result: a no-feed workspace keeps showing its empty state on revisit (no skeleton flash), while the genuine first cold load — where isInitiallyLoadingFeeds is still true, so isNoFeed is false — still shows the skeleton. With-feeds, feed-pending, and the account-ID-0 error state are untouched (isNoFeed is false, or the error branch renders instead).
What alternative solutions did you explore? (Optional)
Please re-state the problem that we are trying to solve in this issue.
On the Workspace settings → Company cards page, the card list reloads (the skeleton loader flashes) every single time the page is opened. After navigating away (e.g. to Categories) and back to Company cards, the page shows a loading state again instead of immediately displaying the already-fetched cards.
What is the root cause of that problem?
The Company cards page fires two data fetches on mount: one for the list of feeds (openPolicyCompanyCardsPage) and one for the selected feed's card list (openPolicyCompanyCardsFeed).
The feeds-list fetch is already guarded so it is skipped once the feeds are present in Onyx:
But the second effect, which fetches the selected feed's card list, has no equivalent "already loaded" guard. It re-runs on every mount and calls openPolicyCompanyCardsFeed unconditionally:
Because the Company cards screen is unmounted when you navigate away and freshly mounted when you return, this effect re-fires on every visit, putting the feed back into a loading state and flashing the skeleton — even though the card list is already cached in Onyx. This is the same class of unnecessary re-fetch that was fixed for the feeds list, but the per-feed card list was left unguarded.
What changes do you think we should make in order to solve the problem?
Add an "already loaded" guard to the feed-loading effect in WorkspaceCompanyCardsPage, mirroring the existing hasFeedsLoaded guard used for the feeds-list fetch.
Concretely, the page already derives the selected feed's card entries through useCompanyCards (companyCardEntries). We compute a boolean such as hasCards = (companyCardEntries ?? []).length > 0 and add it to the effect that calls loadPolicyCompanyCardsFeed, returning early when cards are already present:
So the effect becomes: if the selected feed's cards are already loaded, skip the fetch; otherwise call loadPolicyCompanyCardsFeed(). This keeps the first (cold) load behavior intact — the cards are still fetched when they are not yet cached — while preventing the redundant re-fetch (and the skeleton flash) on every subsequent visit.
The guard is placed in the effect, not inside loadPolicyCompanyCardsFeed itself, so the manual "Try again" reload path (onReloadFeed) that re-uses this callback continues to force a refresh on demand. This matches the established pattern and the table's own "if we already have fetched cards, do not show the skeleton loader" logic.
What alternative solutions did you explore? (Optional)
Keep a previously-fetched-feed signal in Onyx (e.g. gate on the selected feed's status having been written by a prior fetch) instead of deriving from the card entries. This is more precise for empty feeds but more invasive; gating on the already-computed card entries is the minimal change that fixes the reported scenario and stays consistent with the feeds-list guard.
⚠️@mukhrr Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.
@marufsharifi can you please accept the job below? Please reply here and tag me once you have.
If you're not sent an offer in Upwork when you're assigned to an issue, please tag me. If an Upwork job exists, please submit a proposal. https://www.upwork.com/jobs/~022065365683893732639
Activity
MelvinBot commentedon Jun 12, 2026
Proposal
What is the root cause of that problem?
Every time the Company cards page mounts, it unconditionally re-fetches the feed and re-shows the skeleton — even when the cards are already cached in Onyx.
The page has a
useEffectthat fires the feed fetch on every mount with no "already loaded" guard:WorkspaceCompanyCardsPage.tsx:86-88Contrast this with the sibling effect right above it (
L70-76), which does guard withhasFeedsLoadedand skips the fetch when feeds already exist. The feed-level fetch has no equivalent guard.loadPolicyCompanyCardsFeedcallsopenPolicyCompanyCardsFeed, whoseoptimisticDataunconditionally setscardFeedsStatus[feed].isLoading = true. The table reads exactly that flag and renders the skeleton:WorkspaceCompanyCardsTable/index.tsx:105,131-136—areWorkspaceCardFeedsLoading→isLoadingPage→isLoading→TableSkeleton.The lone guard inside
loadPolicyCompanyCardsFeed(L79) checks the page's localisLoading, which is itself based onisLoadingOnyxValue(cardListMetadata)(L66). On remount,useOnyxsubscriptions transition throughstatus: 'loading'for a tick even when the value is cached, so the guard races: it can betrueon the first render andfalseon the next, at which point the effect re-fires the API + the optimisticisLoading: true. Result: the skeleton flashes on every navigation back to the page.Why it reproduces on every navigation
useOnyxmetadata is briefly'loading'.openPolicyCompanyCardsFeed; its optimistic merge setscardFeedsStatus[feed].isLoading = true.WorkspaceCompanyCardsTablereadsareWorkspaceCardFeedsLoadingand renders the skeleton.successDataflipsisLoading: false; cards reappear.Note: this is a long-standing behavior (reported on v9.4.6-0), not specific to the recent refactor in PR #93202 — that PR rewrote this file but the unguarded-fetch pattern persists.
What changes do you think we should make in order to solve the problem?
Add an "already loaded" guard to the feed fetch, mirroring the existing
hasFeedsLoadedguard on the sibling effect:loadPolicyCompanyCardsFeed(or itsuseEffect), skip the call when the selected feed's cards are already present in Onyx (e.g.cardsList/companyCardEntriesis non-empty, orcardListMetadata.status === 'loaded'). This prevents the redundantOpenPolicyCompanyCardsFeedcall on remount.openPolicyCompanyCardsFeed's optimisticisLoading: truewrite conditional on there being no cached cards, so the skeleton only shows on the genuine first load.This keeps the first-load behavior intact while eliminating the skeleton flash on subsequent visits.
What alternative solutions did you explore? (Optional)
WorkspaceCompanyCardsTableso it never shows while cached cards exist (treat the refetch as a background refresh). This addresses the symptom but still issues a redundant API call on every mount, so the guard on the fetch is preferred.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/93404)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
aswin-s commentedon Jun 12, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Web, when a user navigates from a workspace's Company cards page to another workspace page (e.g. Categories) and back, the Company cards page re-fetches the feed and flashes the loading skeleton on every revisit, instead of rendering the already-cached cards immediately.
What is the root cause of that problem?
In
src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsx, the effect at lines 86–88 callsloadPolicyCompanyCardsFeed()on every mount without checking whether the feed's card list is already loaded. The internal guards inloadPolicyCompanyCardsFeed(lines 78–84) only short-circuit onisLoading/!bankName/isFeedPending/isOffline— none of which are true on a revisit when the cards are already cached — so it callsopenPolicyCompanyCardsFeed, which optimistically writescardFeedsStatus[feed].isLoading: true(src/libs/actions/CompanyCards.tslines 966–981). That flips the table into its skeleton state until the network response returns. The sibling effect forloadPolicyCompanyCardsPage(lines 70–76) avoids the same issue with ahasFeedsLoadedguard; the feed effect has no equivalent.What changes do you think we should make in order to solve the problem?
src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsxlines 86–88: gate the effect with a "cards already loaded for this feed" check, mirroring thehasFeedsLoadedpattern used at line 71. Skip the call whencardsListfor the currentfeedNameis already present and non-empty (i.e. derivehasCardsLoadedfromcompanyCards.cardList/assignedCardsor checkcardListMetadata.status === 'loaded'together with a non-undefined value).src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsxline 84: drop unneeded reactive deps fromloadPolicyCompanyCardsFeed(e.g.isLoading) so the callback identity is stable across re-renders within the same mount, preventing redundant effect re-runs even if the guard above is bypassed.onReloadFeedpath (passed toWorkspaceCompanyCardsTableline 117) unchanged so users can still explicitly refresh.What alternative solutions did you explore? (Optional)
Tracking a "fetched once per (policyID, feedName)" ref to suppress re-fetch on remount — rejected because Onyx already holds the cached cards; a data-driven guard (option 1) is simpler and survives provider remounts.
lorretheboy commentedon Jun 12, 2026
Proposal
What is the root cause of that problem?
On every mount the page decides whether to refetch feeds using only whether
allCardFeedscurrently has keys:App/src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsx
Line 68 in 3a8833f
App/src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsx
Lines 70 to 76 in 3a8833f
When you leave the page (to Categories) and come back, the component remounts and the
useCardFeedsOnyx subscription re-hydrates from cache. On the first renderallCardFeedsis stillundefined(statusloading), sohasFeedsLoadedisfalseand the effect firesopenPolicyCompanyCardsPageagain — even though the data is already cached and about to arrive. That call optimistically sets the domain-memberisLoading: trueflag, which the table reads asareWorkspaceCardFeedsLoadingand turns into the skeleton:App/src/components/Tables/WorkspaceCompanyCardsTable/index.tsx
Line 134 in 3a8833f
So the chain is: remount → feeds collection briefly loading from cache →
hasFeedsLoadedfalse → guard ignores the loading state → spuriousOpenPolicyCompanyCardsPagerefetch →isLoadingflag flips on while cards haven't rebuilt yet → full skeleton flashes on every visit.What changes do you think we should make in order to solve the problem?
Don't treat "feeds collection is still hydrating" as "feeds not loaded".
useCompanyCardsalready exposesisInitiallyLoadingFeeds(=isLoadingOnyxValue(allCardFeedsMetadata)):App/src/hooks/useCompanyCards.ts
Line 182 in 3a8833f
Destructure it on the page and add it to the guard so the refetch only fires once the cache has actually settled and there are genuinely no feeds:
App/src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsx
Lines 70 to 76 in 3a8833f
(add
isInitiallyLoadingFeedsto the dependency array). A true first-time load still works: onceisInitiallyLoadingFeedsresolves tofalsewith no feeds, the fetch fires as before — but a revisit with cached feeds no longer refetches, so the skeleton stops flashing.What alternative solutions did you explore? (Optional)
Cache the "already fetched this policy" decision in a ref/Onyx flag so the fetch only runs once per session. This avoids the hydration race too, but it adds extra state to manage and still re-runs after a genuine cache eviction; gating on the existing loading metadata is the smaller, more direct fix.
melvin-bot commentedon Jun 12, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @marufsharifi (
External)[-]Workspace setting- Company cards page loads each time opening it[/-][+][$250] Workspace setting- Company cards page loads each time opening it[/+]melvin-bot commentedon Jun 12, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022065365683893732639
yusufdeveloper2903 commentedon Jun 12, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-06-15 07:03:30 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On the Workspace Company cards page, the card list re-runs its loading state (skeleton) every time you navigate away to another workspace page (e.g. Categories) and come back, even though the data is already cached. Re-opening the page should not re-trigger a load.
What is the root cause of that problem?
WorkspaceCompanyCardsPagehas two data-loading effects, each of which drives a skeleton via an optimisticisLoading: true, and they fail to skip on a revisit for two distinct reasons.1. The feed-cards effect has no "already loaded" guard. It calls
loadPolicyCompanyCardsFeed()unconditionally on every mount:https://github.com/Expensify/App/blob/main/src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsx#L86-L88
On a revisit it re-fires
openPolicyCompanyCardsFeed, which optimistically writescardFeedsStatus[feed].isLoading = true:https://github.com/Expensify/App/blob/main/src/libs/actions/CompanyCards.ts#L966-L981
That surfaces as
selectedFeed.statusand feeds straight into the table'sisLoadingFeed→ skeleton flash on every open:https://github.com/Expensify/App/blob/main/src/components/Tables/WorkspaceCompanyCardsTable/index.tsx#L131-L136
2. The page-load guard is a presence check, so a no-feed workspace never settles.
hasFeedsLoadedonly becomestrueonce a feed key exists:https://github.com/Expensify/App/blob/main/src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsx#L68-L76
For a workspace with zero feeds,
allCardFeedsstays empty forever, sohasFeedsLoadedis permanentlyfalse. Every revisit re-firesopenPolicyCompanyCardsPage, which optimistically re-sets the domain-member rootisLoading: true→ the table reads it asareWorkspaceCardFeedsLoading→isLoadingPage→ skeleton. The feed-level guard can't help here because there is noselectedFeed.(Note: for a workspace with feeds, the page effect is already safe —
allCardFeedsis a cachedSHARED_NVP_PRIVATE_DOMAIN_MEMBERcollection, souseOnyxreturnsstatus: 'loaded'synchronously on the first render after remount andhasFeedsLoadedistrueon render #1. So the page-level fetch only needs the no-feed fix, while the feed-level fetch needs the missing guard.)What changes do you think we should make in order to solve the problem?
Guard both effects on a resolved Onyx status (
isLoading === false) — the signal that persists inSHARED_NVP_PRIVATE_DOMAIN_MEMBERacross the remount — instead of on value presence. A genuine first load (status === undefined) still fires; a revisit refetches neither.1. Page-load effect — covers the no-feed workspace:
isInitiallyLoadingFeedsgates the cold-start hydration window: whileallCardFeedsis still hydrating,workspaceCardFeedsStatusis empty, so the resolved-status check would readundefined === falseand fire a wasteful fetch before the persisted status is even available. It'sstatus === 'loading'(set only onisFirstConnection && hasPendingMergeForKey), guaranteed to flip tofalseonce the initial read settles — so it can never block the genuine first load.2. Feed-load effect — covers the cached-feed revisit, on
=== false(not just truthy) so an interrupted{isLoading: true}self-heals instead of stranding the skeleton:useEffect(() => { + if (isOffline || selectedFeed?.status?.isLoading === false) { + return; + } loadPolicyCompanyCardsFeed(); - }, [loadPolicyCompanyCardsFeed]); + }, [loadPolicyCompanyCardsFeed, isOffline, selectedFeed?.status?.isLoading]);workspaceCardFeedsStatus,selectedFeedandisInitiallyLoadingFeedsare already available fromuseCompanyCards, so no new Onyx wiring is needed.Net rule on both effects:
undefined→ load,{isLoading: false}→ skip,{isLoading: true}→ self-heal. Why it's correct across the edge cases:isLoading: falseon first success → no refetch on revisit (the presence check alone never could).selectedFeed.status.isLoading === false→ feed fetch skipped, no skeleton flash.isInitiallyLoadingFeeds), the page effect defers instead of reading the not-yet-hydrated root status; once settled it skips (resolved) or fires the first load (never fetched).undefined→ both fetches still fire once.bankName/selectedFeed; the new feed's status isundefined→ it loads.{isLoading: true}): falls through and self-heals instead of stranding the page.onReloadPage/onReloadFeedand the existing offline/pending/bankName guards inside the callbacks still apply.What alternative solutions did you explore? (Optional)
isLoadingwhen cards already exist — papers over the symptom (the skeleton) while still firing redundantOPEN_POLICY_COMPANY_CARDS_PAGE/OPEN_POLICY_COMPANY_CARDS_FEEDrequests on every open.useRef"already fetched" flag — a ref resets on unmount, so it doesn't survive the revisit; the Onyx-backed resolved status is the only signal that persists across the remount.cardList/ card-entry presence — regresses valid feeds (and workspaces) that resolved with zero cards, since presence never becomes truthy for them.mukhrr commentedon Jun 12, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-06-12 13:54:06 UTC.
Proposal
What is the root cause of that problem?
On a workspace with no company card feeds, the loading skeleton re-appears every time the Company cards page is opened.
The skeleton is driven by the table's
isLoadingPage, which includesareWorkspaceCardFeedsLoading— the optimisticisLoadingflag on the domain member:App/src/components/Tables/WorkspaceCompanyCardsTable/index.tsx
Line 134 in 7af4b0e
App/src/components/Tables/WorkspaceCompanyCardsTable/index.tsx
Line 105 in 7af4b0e
OpenPolicyCompanyCardsPagere-fetches on every visit and optimistically sets that flag back totrue:App/src/libs/actions/CompanyCards.ts
Lines 907 to 922 in 7af4b0e
For a workspace with no feeds there are no cached cards to suppress the loader (
hasCardsisfalse), so the skeleton flashes on every revisit. Compare this with Categories/Tags: they also fetch on every visit, but gate their skeleton on a durable per-policy data key that a refetch never resets, so it never re-flashes:App/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx
Line 564 in 7af4b0e
The company cards skeleton instead keys off the transient optimistic flag — and that flag isn't durable either: the backend re-sends the
sharedNVP_private_domain_memberNVP without it on navigation, so any "loaded once" marker stored there is wiped between visits (I confirmed this at runtime — the flag readfalseon one mount andundefinedon the very next visit).What changes do you think we should make in order to solve the problem?
Keep fetching on every visit (consistent with Categories/Tags), and stop the skeleton from being driven by the optimistic flag once we've already resolved that the workspace has no feeds.
In
WorkspaceCompanyCardsTable, add!isNoFeedtoisLoadingPage:isNoFeedis derived from the feeds collection's Onyx metadata, not the optimistic flag, so it staystruethrough the background refetch — the company-cards analog of Categories' durablepolicyCategories:App/src/hooks/useCompanyCards.ts
Lines 182 to 183 in 7af4b0e
This mirrors the
!isNoFeedguard already used one line above inisLoadingFeed:App/src/components/Tables/WorkspaceCompanyCardsTable/index.tsx
Lines 131 to 132 in 7af4b0e
Result: a no-feed workspace keeps showing its empty state on revisit (no skeleton flash), while the genuine first cold load — where
isInitiallyLoadingFeedsis stilltrue, soisNoFeedisfalse— still shows the skeleton. With-feeds, feed-pending, and the account-ID-0 error state are untouched (isNoFeedisfalse, or the error branch renders instead).What alternative solutions did you explore? (Optional)
n/a
wildan-m commentedon Jun 12, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
On the Workspace settings → Company cards page, the card list reloads (the skeleton loader flashes) every single time the page is opened. After navigating away (e.g. to Categories) and back to Company cards, the page shows a loading state again instead of immediately displaying the already-fetched cards.
What is the root cause of that problem?
The Company cards page fires two data fetches on mount: one for the list of feeds (
openPolicyCompanyCardsPage) and one for the selected feed's card list (openPolicyCompanyCardsFeed).The feeds-list fetch is already guarded so it is skipped once the feeds are present in Onyx:
App/src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsx
Lines 70 to 76 in 3a8833f
But the second effect, which fetches the selected feed's card list, has no equivalent "already loaded" guard. It re-runs on every mount and calls
openPolicyCompanyCardsFeedunconditionally:App/src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsx
Lines 86 to 88 in 3a8833f
openPolicyCompanyCardsFeedoptimistically sets the feed'sisLoadingto true:App/src/libs/actions/CompanyCards.ts
Lines 966 to 981 in 3a8833f
Because the Company cards screen is unmounted when you navigate away and freshly mounted when you return, this effect re-fires on every visit, putting the feed back into a loading state and flashing the skeleton — even though the card list is already cached in Onyx. This is the same class of unnecessary re-fetch that was fixed for the feeds list, but the per-feed card list was left unguarded.
What changes do you think we should make in order to solve the problem?
Add an "already loaded" guard to the feed-loading effect in
WorkspaceCompanyCardsPage, mirroring the existinghasFeedsLoadedguard used for the feeds-list fetch.Concretely, the page already derives the selected feed's card entries through
useCompanyCards(companyCardEntries). We compute a boolean such ashasCards = (companyCardEntries ?? []).length > 0and add it to the effect that callsloadPolicyCompanyCardsFeed, returning early when cards are already present:App/src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsx
Lines 86 to 88 in 3a8833f
So the effect becomes: if the selected feed's cards are already loaded, skip the fetch; otherwise call
loadPolicyCompanyCardsFeed(). This keeps the first (cold) load behavior intact — the cards are still fetched when they are not yet cached — while preventing the redundant re-fetch (and the skeleton flash) on every subsequent visit.The guard is placed in the effect, not inside
loadPolicyCompanyCardsFeeditself, so the manual "Try again" reload path (onReloadFeed) that re-uses this callback continues to force a refresh on demand. This matches the established pattern and the table's own "if we already have fetched cards, do not show the skeleton loader" logic.Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/93404-company-cards-skeleton-flash?expand=1
What alternative solutions did you explore? (Optional)
Keep a previously-fetched-feed signal in Onyx (e.g. gate on the selected feed's
statushaving been written by a prior fetch) instead of deriving from the card entries. This is more precise for empty feeds but more invasive; gating on the already-computed card entries is the minimal change that fixes the reported scenario and stays consistent with the feeds-list guard.github-actions commentedon Jun 12, 2026
131 remaining items
melvin-bot commentedon Jul 22, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Jul 22, 2026
Payment Summary
Upwork Job
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Jul 24, 2026
Payment Summary
Contributor: @nkdengineer paid $250 via NewDot
Contributor+: @marufsharifi due $250 via Upwork
@marufsharifi can you please accept the job below? Please reply here and tag me once you have.
If you're not sent an offer in Upwork when you're assigned to an issue, please tag me. If an Upwork job exists, please submit a proposal.
https://www.upwork.com/jobs/~022065365683893732639
^ Test case created. Thx
marufsharifi commentedon Jul 25, 2026
@mallenexpensify, I've accepted the offer. thanks.
mallenexpensify commentedon Jul 27, 2026
@marufsharifi paid, summary updated above. Thx.
twisterdotcom commentedon Aug 18, 2026
$250 approved for @nkdengineer in Report ID: R00HUzY8dIps.
Zapier Logs
Run ID: 00040eee-748a-ab0c-24f9-0462af69b334SO: https://stackoverflowteams.com/c/expensify/questions/7582