[Due for payment 2026-12-08] [$175] Company cards- Toggle doesn't show a pending state after being changed offline
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: 9.5.40-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: https://github.com/Expensify/App/pull/106795 Email or phone of affected tester (no customers): n/a Issue reported by: Applause Internal Team Bug source: Pull Request QA execution Device used: Mav 26.5.1 Safari, iPhone 13 iOS 26.6 App Component: Workspace Settings
Action Performed:
- Go to https://staging.new.expensify.com
- Sign in as a workspace admin on a workspace that has a company card feed
- Go to Workspaces > [workspace] > Company cards
- Go offline
- Click Settings
- Turn the "Allow cardholders to delete transactions" toggle on or off
Expected Result:
The "Allow cardholders to delete transactions" toggle should show a pending state after being changed while offline
Actual Result:
The toggle does not show a pending state after being changed while offline
Workaround:
Unknown
Platforms:
- [ ] Android: App
- [ ] Android: mWeb Chrome
- [x] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [x] Windows: Chrome
- [x] MacOS: Chrome Safari
Screenshots/Videos
https://github.com/user-attachments/assets/829c8470-0360-4e70-8396-36997acef7ba
Applause Internal Information Exported by: Julia Ponikarchuk Bug ID: 7316109
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022122563573866893888
- Upwork Job ID: 2122563573866893888
- Last Price Increase: 2026-11-17
Issue Owner
Current Issue Owner: @suneox
While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/1846f1a6dd6ca8973ccee941d911e5f9f87eed2afa02ec4e4ad82428af7847d9
Triggered auto assignment to Contributor-plus team member for initial proposal review - @suneox (External)
Job added to Upwork: https://www.upwork.com/jobs/~022122563573866893888
Proposal
What is the root cause of that problem?
The toggle changes its value optimistically, but both parts of its pending-state handling are missing: the action does not record a pending update, and the toggle does not receive a pending action to display.
Confidence: Medium — supported by the client code; not independently reproduced in a browser.
Code evidence
- CompanyCards.ts:338–363 updates
liabilityTypeoptimistically but supplies no pending metadata or completion cleanup. - WorkspaceCompanyCardsSettingsPage.tsx:189–199 renders the toggle without
pendingAction. Itsdisabledprop is not pending feedback. - The shared toggle already supports pending feedback through ToggleSettingsOptionRow.tsx:248–255. OfflineWithFeedback.tsx:94–100 applies offline pending opacity.
This explains why the switch changes position without appearing pending.
What changes do you think we should make in order to solve the problem?
- Record
pendingFields.liabilityType = UPDATEalongside the optimistic value. - Clear that field on success and failure; restore the previous value on failure.
- Pass the field into the toggle’s existing
pendingActionprop. No additional feedback wrapper is needed. - Cover both workspace-owned and domain-owned feeds, both toggle directions, reconnection, rejection, and repeated offline toggles.
Feed-combination edge case and regression coverage
CardFeedUtils.ts:590–609 lets OAuth properties override feed settings. An OAuth pendingFields map could therefore hide the new liability pending field.
Add tests with conflicting OAuth metadata. Where necessary, extend the existing local-change override pattern specifically for liability updates, preserving normal OAuth precedence otherwise. This is a conditional risk, not a confirmed characteristic of the reported feed.
The existing CompanyCardsLiabilityTest.ts:16–39 checks account targeting, but not pending-state behavior.
What alternative solutions did you explore? (Optional)
A shared styling defect does not explain the missing metadata and prop. Adding only the UI prop—or only the action metadata—would leave the other half disconnected.
The QA-linked Clarify cardholder transaction deletion setting copy changed translations only; there is no evidence that it introduced this defect.
Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/107077) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On a workspace with a company card feed, toggling "Allow cardholders to delete transactions" while offline flips the switch but shows no pending state — the change looks applied immediately even though it has not reached the server.
What is the root cause of that problem?
Both halves of the pending handling are missing. setWorkspaceCompanyCardTransactionLiability (src/libs/actions/CompanyCards.ts:338-363) writes only {liabilityType} in its optimistic data — no pendingFields entry and no success/failure cleanup — even though the same file's deleteWorkspaceCompanyCardFeed (:365+) already records pendingAction: DELETE in its optimistic updates. On the UI side, WorkspaceCompanyCardsSettingsPage.tsx:189-199 renders the toggle with no pendingAction and no OfflineWithFeedback wrapper, while the sibling rows on the same page (lines 169, 179) wrap their controls in OfflineWithFeedback pendingAction={selectedFeedData?.pendingFields?.<field>}. ToggleSettingsOptionRow already accepts a pendingAction prop (ToggleSettingsOptionRow.tsx:86, passed through at :250), and the toggle's disabled={isPending} only reads the feed-level pending flag (line 80), which this write never sets.
What changes do you think we should make in order to solve the problem?
- In
setWorkspaceCompanyCardTransactionLiability, recordpendingFields: {liabilityType: UPDATE}in the optimistic data, clear it on success, and on failure restore the previous liability value and clear the field. - Pass
selectedFeedData?.pendingFields?.liabilityTypeas the toggle'spendingAction(or wrap the row inOfflineWithFeedbacklike its siblings) so the existing pending opacity/feedback applies. - Cover workspace-owned and domain-owned feeds, both toggle directions, reconnection, rejection, and repeated offline toggles. Edge case to check:
CardFeedUtils.ts:590-609lets OAuth properties override feed settings, so verify an OAuthpendingFieldsmap cannot hide the new liability pending field — extend the existing local-change override pattern for liability updates if needed.
What alternative solutions did you explore? (Optional)
Adding only the UI prop or only the action metadata would leave the other half disconnected — the bug is the missing pair, not either side alone. The QA-linked PR #106795 changed translations only and did not introduce this.
How will you verify the fix?
Toggle the setting offline and confirm the pending state shows; reconnect and confirm it clears; simulate a failed write and confirm the previous value is restored with the error shown; repeat for both toggle directions and both feed ownership types. Add unit tests in the style of tests/actions/CompanyCardsLiabilityTest.ts covering the pending-field lifecycle.
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01c5c6bc0e7d162f7b
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Hi @suneox,
I'm interested in contributing to this issue and would appreciate being considered when it becomes available for external contributors.
I've reviewed the relevant implementation and existing proposals. The reported behavior appears to involve two missing pieces in the optimistic update lifecycle:
setWorkspaceCompanyCardTransactionLiabilityupdatesliabilityTypewithout recording the correspondingpendingFields.liabilityTypestate or defining its success/failure cleanup.WorkspaceCompanyCardsSettingsPagedoes not forward that pending state toToggleSettingsOptionRow, even though the shared component already supports offline feedback.
Additional areas I'd like to investigate
Beyond the straightforward pending-state fix, I believe it's worth validating a few edge cases before implementation:
- OAuth feed merging: Confirm that locally pending liability changes remain visible when
CardFeedUtilscombines feed settings with OAuth account metadata. - Repeated offline updates: Verify that multiple toggle changes made before reconnection resolve consistently, without stale responses overwriting newer state.
- Failure recovery: Ensure unsuccessful updates restore the appropriate previous state, clear pending metadata, and expose errors correctly.
- Regression coverage: Add focused tests for workspace-owned and domain-owned feeds, both toggle directions, successful synchronization, and rejected updates.
These are verification targets rather than claims of additional confirmed bugs.
Contribution request
I noticed the issue is marked External but has not yet received the Help Wanted label. I also recognize that other proposals have already been submitted, so I don't want to duplicate their work or bypass the contribution process.
Could you please confirm whether additional contributors will be considered once the issue becomes eligible?
I'd be glad to prepare a focused, evidence-backed proposal and implementation, including regression tests, if there's an opportunity to contribute.
Thank you for your consideration!
Contributor details Your Expensify account email: [email protected]
Proposal
Please re-state the problem that we are trying to solve in this issue.
When changing the "Allow cardholders to delete transactions" toggle while offline on the Company Cards Settings page (WorkspaceCompanyCardsSettingsPage), the toggle updates its local state but does not display any pending state (dashed border / dimmed pending opacity) to indicate that the update is queued offline.
What is the root cause of that problem?
The bug is caused by two missing connections in the optimistic update and UI feedback lifecycle:
-
Missing
pendingFieldsin action (src/libs/actions/CompanyCards.ts:338–363): InsetWorkspaceCompanyCardTransactionLiability, the optimistic write only updates{liabilityType}insettings.companyCards[bankName]:const feedUpdates = { [bankName]: {liabilityType}, };It completely omits
pendingFields: {liabilityType: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}anderrorFields: {liabilityType: null}fromoptimisticData. Additionally, it does not specifysuccessDatato clearpendingFields.liabilityType: null, nor does it providefailureDatato rollbackliabilityTypeto its previous value and expose errors on network rejection. -
Missing
OfflineWithFeedbackwrapper in UI (src/pages/workspace/companyCards/WorkspaceCompanyCardsSettingsPage.tsx:189–199): TheToggleSettingOptionRowis rendered inside a plain<View style={[styles.mv3, styles.mh5]}>without<OfflineWithFeedback>. Unlike its sibling settings right above it (statementPeriodEndDayat line 169 andforceReimbursableat line 179), it has no connection toselectedFeedData?.pendingFields?.liabilityType. Thus, offline opacity and pending visual cues are never rendered.
What changes do you think we should make in order to solve the problem?
-
Update
setWorkspaceCompanyCardTransactionLiabilityinsrc/libs/actions/CompanyCards.ts: SupportoldLiabilityTypeand provide completeoptimisticData,successData, andfailureData:function setWorkspaceCompanyCardTransactionLiability( domainOrWorkspaceAccountID: number, policyID: string, bankName: CompanyCardFeedWithNumber, liabilityType: string, oldLiabilityType?: string, ) { const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER>> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`, value: { settings: { companyCards: { [bankName]: { liabilityType, pendingFields: { liabilityType: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, errorFields: { liabilityType: null, }, }, }, }, }, }, ]; const successData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER>> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`, value: { settings: { companyCards: { [bankName]: { pendingFields: { liabilityType: null, }, }, }, }, }, }, ]; const failureData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER>> = [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`, value: { settings: { companyCards: { [bankName]: { ...(oldLiabilityType ? {liabilityType: oldLiabilityType} : {}), pendingFields: { liabilityType: null, }, errorFields: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), }, }, }, }, }, ]; const parameters = { policyID, domainAccountID: domainOrWorkspaceAccountID, bankName, liabilityType, }; API.write(WRITE_COMMANDS.SET_COMPANY_CARD_TRANSACTION_LIABILITY, parameters, {optimisticData, successData, failureData}); } -
Update
WorkspaceCompanyCardsSettingsPage.tsx(src/pages/workspace/companyCards/WorkspaceCompanyCardsSettingsPage.tsx):- Forward
selectedFeedData?.liabilityTypetoonToggleLiability:const onToggleLiability = (isOn: boolean) => { if (!feed) { return; } setWorkspaceCompanyCardTransactionLiability( domainOrWorkspaceAccountID, policyID, feed, isOn ? CONST.COMPANY_CARDS.DELETE_TRANSACTIONS.ALLOW : CONST.COMPANY_CARDS.DELETE_TRANSACTIONS.RESTRICT, selectedFeedData?.liabilityType, ); }; - Wrap the toggle block in
<OfflineWithFeedback>connected toclearErrorField(matching lines 169 & 179):<OfflineWithFeedback pendingAction={selectedFeedData?.pendingFields?.liabilityType} errors={selectedFeedData?.errorFields?.liabilityType} onClose={() => clearErrorField(feed, domainOrWorkspaceAccountID, 'liabilityType')} > <View style={[styles.mv3, styles.mh5]}> <ToggleSettingOptionRow title={translate('workspace.moreFeatures.companyCards.personal')} switchAccessibilityLabel={translate('workspace.moreFeatures.companyCards.personal')} switchSentryLabel={CONST.SENTRY_LABEL.WORKSPACE.COMPANY_CARDS.PERSONAL_LIABILITY_SWITCH} onToggle={onToggleLiability} isActive={isPersonal} disabled={isPending} /> <Text style={[styles.mutedTextLabel, styles.mt2]}>{translate('workspace.moreFeatures.companyCards.setTransactionLiabilityDescription')}</Text> </View> </OfflineWithFeedback>
- Forward
-
Automated Unit Testing: Extend
tests/actions/CompanyCardsLiabilityTest.tsto assert that:optimisticDatacontainspendingFields.liabilityType: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATEanderrorFields.liabilityType: null.successDatasetspendingFields.liabilityType: null.failureDatarestoresoldLiabilityTypeand setserrorFields.liabilityType.
What alternative solutions did you explore? (Optional)
- Passing
pendingActiondirectly toToggleSettingOptionRowwithout<OfflineWithFeedback>: Rejected becauseOfflineWithFeedbackprovides full container dimming, error display, and dismissal handling (onClose), ensuring visual and behavioral consistency across all company card feed settings.
📋 Proposal
Please re-state the problem that we are trying to solve in this issue.
On a workspace with a company card feed, navigating to Workspaces > [Workspace] > Company cards > Settings while offline and toggling the "Allow cardholders to delete transactions" switch flips the switch immediately, but does not render a pending state (the standard dimmed/dashed offline indicator), unlike the other settings on the same page (Statement Close Date and Mark card transactions as reimbursable).
What is the root cause of that problem?
There are two distinct root causes working together:
-
Missing Pending & Error State in Action (
src/libs/actions/CompanyCards.ts):
InsetWorkspaceCompanyCardTransactionLiability(...)(lines 352–377), the action only dispatches an optimistic update containing the rawliabilityType:const feedUpdates = { [bankName]: {liabilityType}, };Unlike standard Expensify offline-first mutations (such as
setWorkspaceCompanyCardForceReimbursable), it completely omits:pendingFields: {liabilityType: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}inoptimisticDatasuccessDataclearingpendingFields: {liabilityType: null}failureDatarevertingliabilityType: oldLiabilityTypeand clearingpendingFields: {liabilityType: null}witherrorFields: {liabilityType: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage')}.
-
Missing
OfflineWithFeedbackwrapper in the UI (src/pages/workspace/companyCards/WorkspaceCompanyCardsSettingsPage.tsx):
In lines 189–199, while the other settings (statementPeriodEndDayandforceReimbursable) are wrapped in<OfflineWithFeedback pendingAction={...}>,ToggleSettingOptionRowis rendered inside a plain<View style={[styles.mv3, styles.mh5]}>without anyOfflineWithFeedbackcomponent, meaning that even ifpendingFieldswere updated in Onyx, the UI has no container to render the pending visual state.
What changes do you think we should make in order to solve the problem?
1. In src/libs/actions/CompanyCards.ts:
Update setWorkspaceCompanyCardTransactionLiability to accept oldLiabilityType?: string and construct full optimisticData, successData, and failureData adhering to the standard company card feed mutation pattern:
function setWorkspaceCompanyCardTransactionLiability(
domainOrWorkspaceAccountID: number,
policyID: string,
bankName: CompanyCardFeedWithNumber,
newLiabilityType: string,
oldLiabilityType?: string,
) {
const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER>> = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`,
value: {
settings: {
companyCards: {
[bankName]: {
liabilityType: newLiabilityType,
pendingFields: {
liabilityType: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
errorFields: {
liabilityType: null,
},
},
},
},
},
},
];
const successData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER>> = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`,
value: {
settings: {
companyCards: {
[bankName]: {
pendingFields: {
liabilityType: null,
},
},
},
},
},
},
];
const failureData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER>> = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${domainOrWorkspaceAccountID}`,
value: {
settings: {
companyCards: {
[bankName]: {
liabilityType: oldLiabilityType ?? null,
pendingFields: {
liabilityType: null,
},
errorFields: {
liabilityType: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'),
},
},
},
},
},
},
];
const parameters = {
policyID,
domainAccountID: domainOrWorkspaceAccountID,
bankName,
liabilityType: newLiabilityType,
};
API.write(WRITE_COMMANDS.SET_COMPANY_CARD_TRANSACTION_LIABILITY, parameters, {
optimisticData,
successData,
failureData,
});
}
2. In src/pages/workspace/companyCards/WorkspaceCompanyCardsSettingsPage.tsx:
- Pass
liabilityType(the current value) asoldLiabilityTypeinsideonToggleLiability:
const onToggleLiability = (isOn: boolean) => {
if (!feed) {
return;
}
setWorkspaceCompanyCardTransactionLiability(
domainOrWorkspaceAccountID,
policyID,
feed,
isOn ? CONST.COMPANY_CARDS.DELETE_TRANSACTIONS.ALLOW : CONST.COMPANY_CARDS.DELETE_TRANSACTIONS.RESTRICT,
liabilityType,
);
};
- Wrap the toggle row in
<OfflineWithFeedback>:
<OfflineWithFeedback
pendingAction={selectedFeedData?.pendingFields?.liabilityType}
errors={selectedFeedData?.errorFields?.liabilityType}
onClose={() => clearCompanyCardFeedError(domainOrWorkspaceAccountID, feed, 'liabilityType')}
style={[styles.mv3, styles.mh5]}
>
<ToggleSettingOptionRow
title={translate('workspace.moreFeatures.companyCards.personal')}
switchAccessibilityLabel={translate('workspace.moreFeatures.companyCards.personal')}
switchSentryLabel={CONST.SENTRY_LABEL.WORKSPACE.COMPANY_CARDS.PERSONAL_LIABILITY_SWITCH}
onToggle={onToggleLiability}
isActive={isPersonal}
disabled={isPending}
/>
<Text style={[styles.mutedTextLabel, styles.mt2]}>{translate('workspace.moreFeatures.companyCards.setTransactionLiabilityDescription')}</Text>
</OfflineWithFeedback>
3. Clear error helper (clearCompanyCardFeedError):
Ensure a cleanup action exists or is added in CompanyCards.ts to clear errorFields.liabilityType on close, identical to clearCompanyCardFeedError.
What alternative solutions did you consider?
- Passing
pendingActiondirectly insideToggleSettingOptionRow.
Discarded:ToggleSettingOptionRowis a shared presentational component across multiple workspace pages without internalOfflineWithFeedbackwrapping. Wrapping it at the parent page level preserves consistency withMenuItemFieldusage throughoutWorkspaceCompanyCardsSettingsPage.
Automated Tests
- Offline Pending State Test:
- Set network to offline via Network state mock.
- Toggle "Allow cardholders to delete transactions".
- Verify that
selectedFeedData.pendingFields.liabilityTypeis'update'and the row renders dimmed with pending feedback. - Go back online and mock server response.
- Verify
pendingFields.liabilityTypeis cleared.
Proposal
What is the root cause of that problem?
The transaction-liability toggle updates its value optimistically, but the action and UI do not provide the field-level pending signal required by the existing offline feedback component.
In CompanyCards.ts, setWorkspaceCompanyCardTransactionLiability writes liabilityType in optimisticData, without a corresponding pending field, success cleanup or failure rollback.
In WorkspaceCompanyCardsSettingsPage.tsx, the toggle does not receive pendingFields.liabilityType. Its existing disabled state comes from a separate feed-level value and does not supply offline feedback. ToggleSettingOptionRow already contains OfflineWithFeedback; adding another wrapper is unnecessary.
What changes do you think we should make in order to solve the problem?
Complete the field-level optimistic lifecycle:
- Capture the previous liability value before updating.
- Set
pendingFields.liabilityTypetoUPDATE. - Clear that field after success.
- On failure, restore the previous value, clear its pending state and provide a field-specific error.
- Preserve unrelated pending and error fields through nested merges.
Pass the liability pending field, errors and a field-specific error-dismiss handler to the existing toggle component. Preserve its current disabled behavior rather than introducing a new global restriction.
Add action coverage for optimistic updates, successful cleanup, rejection rollback and preservation of unrelated fields. Verify both toggle directions, offline feedback, retry and rapid successive changes.
These checks are proposed; I have not run the application tests or reproduced the offline flow independently.
What alternative solutions did you explore? (Optional)
Changing the shared toggle component, adding a duplicate offline wrapper, or using a feed-wide pending state would broaden the change unnecessarily. The adjacent settings already establish the field-level pattern.
@khizzcr7 @himanshu051116 @gorky117-cell @TassioSales @Vallejo1921 Thanks for your interest! This issue doesn't have the Help Wanted label yet, so it isn't open for external proposals. Please take a look at our CONTRIBUTING.md and follow Finding a job that Expensify posted — only issues with the Help Wanted label are open for proposals.
@suneox Use the Connect GitHub link in our earlier Slack DM. I will continue the original request once you are connected.
Triggered auto assignment to @francoisl, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
@MelvinBot Implement this
@suneox I sent you a Slack DM to connect GitHub. I will continue the original request once you are connected.
@MelvinBot resend me connect gitHub link
@suneox I sent you a Slack DM to connect GitHub. I will continue the original request once you are connected.
@MelvinBot Implement this