Skip to content

[$250] Unassigning company card offline removes it optimistically instead of making it strike through #78575

Closed

Description

@nlemma

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.2.88-5
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://test-management.browserstack.com/projects/2219752/folder/13176706/test-cases/41236848
Email or phone of affected tester (no customers): applausetester+ccardfeed@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: macOS 26.1
App Component: Workspace Settings

Action Performed:

  1. Navigate to staging.new.expensify.com
  2. Create a workspace and assign a company card
  3. Go offline
  4. Unassign a card

Expected Result:

The unassigned card gets shown as strike through or greyed out signaling a pending action like in the other pages for offline behavior.

Actual Result:

The unassigned card gets removed optimistically.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

2025-12-30.13-12-43.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022008194600337682401
  • Upwork Job ID: 2008194600337682401
  • Last Price Increase: 2026-01-05
Issue OwnerCurrent Issue Owner: @
Issue OwnerCurrent Issue Owner: @

Activity

  1. added
    Daily
    Bug
    on Dec 30, 2025
  2. melvin-bot commented on Dec 30, 2025

    @melvin-bot

    Triggered auto assignment to @zanyrenney (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. nlemma commented on Dec 30, 2025

    @nlemma
    Author

    @m-natarajan tagging you to assign the issue.

  4. ryntgh commented on Dec 30, 2025

    @ryntgh
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-01-09 06:39:45 UTC.

    Proposal

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

    Unassigning company card offline removes it optimistically instead of making it strike through

    What is the root cause of that problem?

    In unassignWorkspaceCompanyCard, the optimistic data sets the card to null in the workspace cards list, which removes it immediately from the UI

    optimisticData: [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bankName}`,
    value: {
    [cardID]: null,
    },
    },

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

    Keep the card in the workspace cards list with a pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE instead of setting it to null in the optimistic data. Only remove it in the success data

                {
                    onyxMethod: Onyx.METHOD.MERGE,
                    key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bankName}`,
                    value: {
                        [cardID]: {
                            ...card,
                            pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
                        },
                    },
                },

    Or conditionally handle optimistic data based on network state

        const isOffline = NetworkStore.isOffline();
    
                {
                    onyxMethod: Onyx.METHOD.MERGE,
                    key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bankName}`,
                    value: {
                        [cardID]: isOffline
                            ? {
                                  ...card,
                                  pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
                              }
                            : null,
                    },
                },

    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bankName}`,
    value: {
    [cardID]: null,
    },
    },

                {
                    onyxMethod: Onyx.METHOD.MERGE,
                    key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bankName}`,
                    value: {
                        [cardID]: {
                            ...card,
                            pendingAction: null,
                            errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'),
                        },
                    },
                },

    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bankName}`,
    value: {
    [cardID]: {
    pendingAction: null,
    errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'),
    },
    },
    },

    We can also add logic to show loading indicator/skeleton loading individually for each card when there are pending unassign requests to prevent it to disappear briefly

        const {isOffline} = useNetwork();
    
        const isDeleting = !isOffline && pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
    
        return (
            <OfflineWithFeedback
                errorRowStyles={[styles.ph5, styles.mb4]}
                errors={errors}
                pendingAction={pendingAction}
                onClose={resetFailedCompanyCardAssignment}
                shouldHideOnDelete={false}
            >
                {isDeleting ? (
                    <TableRowSkeleton fixedNumItems={1} />
                ) : (
                    <PressableWithFeedback
                         ...
                    >
                         ...
                    </PressableWithFeedback>
                )}
            </OfflineWithFeedback>
        );

    return (
    <OfflineWithFeedback
    errorRowStyles={[styles.ph5, styles.mb4]}
    errors={errors}
    pendingAction={pendingAction}
    onClose={resetFailedCompanyCardAssignment}
    >
    <PressableWithFeedback
    role={CONST.ROLE.BUTTON}
    style={[styles.mh5, styles.flexRow, styles.br3, styles.mb2, styles.highlightBG, styles.overflowHidden]}
    accessibilityLabel="row"
    hoverStyle={styles.hoveredComponentBG}
    disabled={isCardDeleted}
    onPress={() => {
    if (!assignedCard) {
    assignCard();
    return;
    }
    if (!assignedCard?.accountID || !assignedCard?.fundID) {
    return;
    }
    const feedName = getCompanyCardFeedWithDomainID(assignedCard?.bank as CompanyCardFeed, assignedCard.fundID);
    return Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARD_DETAILS.getRoute(policyID, feedName, assignedCard.cardID.toString()));
    }}
    >
    {({hovered}) => (
    <View
    style={[
    styles.flex1,
    styles.flexRow,
    styles.alignItemsCenter,
    styles.p4,
    styles.gap3,
    styles.dFlex,
    // Use Grid on web when available (will override flex if supported)
    !shouldUseNarrowTableLayout && [styles.dGrid, {gridTemplateColumns: `repeat(${columnCount}, 1fr)`}],
    ]}
    >
    <View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter, styles.gap3]}>
    {isAssigned ? (
    <Avatar
    source={
    cardholder?.avatar ??
    getDefaultAvatarURL({
    accountID: cardholder?.accountID,
    })
    }
    avatarID={cardholder?.accountID}
    type={CONST.ICON_TYPE_AVATAR}
    size={CONST.AVATAR_SIZE.DEFAULT}
    />
    ) : (
    CardFeedIcon
    )}
    <View style={[styles.flex1, styles.flexColumn, styles.justifyContentCenter, styles.alignItemsStretch]}>
    <TextWithTooltip
    text={leftColumnTitle}
    style={[styles.optionDisplayName, styles.sidebarLinkTextBold, styles.pre, styles.justifyContentCenter]}
    />
    {!!leftColumnSubtitle && (
    <TextWithTooltip
    text={leftColumnSubtitle}
    style={[styles.textLabelSupporting, styles.lh16, styles.pre, styles.mr3]}
    />
    )}
    </View>
    </View>
    {!shouldUseNarrowTableLayout && (
    <View style={[styles.flex1]}>
    <Text
    numberOfLines={1}
    style={[styles.lh16, styles.optionDisplayName, styles.pre]}
    >
    {cardName}
    </Text>
    </View>
    )}
    <View style={[styles.flexRow, styles.flexRow, styles.alignItemsCenter, styles.justifyContentEnd]}>
    {isAssigned ? (
    <View style={[styles.flexRow, styles.ml2, styles.gap3, styles.mw100]}>
    {!shouldUseNarrowTableLayout && (
    <Text
    numberOfLines={1}
    style={[styles.optionDisplayName, styles.pre]}
    >
    {customCardName}
    </Text>
    )}
    <Icon
    src={Expensicons.ArrowRight}
    fill={theme.icon}
    additionalStyles={[styles.alignSelfCenter, !hovered && styles.opacitySemiTransparent]}
    medium
    isButtonIcon
    />
    </View>
    ) : (
    <Button
    success
    small={shouldUseNarrowTableLayout}
    text={translate('workspace.companyCards.assign')}
    onPress={assignCard}
    isDisabled={isAssigningCardDisabled}
    />
    )}
    </View>
    </View>
    )}
    </PressableWithFeedback>
    </OfflineWithFeedback>
    );

    We need to change the card feed icon loading state in WorkspaceCompanyCardsTableItem from spinner to a skeleton as well

    1. Create a new skeleton component CardIconSkeleton.tsx with SkeletonViewContentLoader that accepts width and height props

    2. Update PlaidCardFeedIcon.tsx to add a new prop useSkeletonLoader (defaults to false), then conditionally renders CardIconSkeleton when useSkeletonLoader={true}, otherwise use ActivityIndicator

    <View style={[styles.justifyContentCenter, {width: iconWidth, height: iconHeight}]}>
    <ActivityIndicator size={isSmall ? 10 : 20} />
    </View>

    1. Update CardFeedIcon.tsx to add a new prop useSkeletonLoader (defaults to false), then pass it through to PlaidCardFeedIcon when rendering Plaid card feeds

    <PlaidCardFeedIcon
    plaidUrl={getPlaidInstitutionIconUrl(selectedFeed)}
    // eslint-disable-next-line react/jsx-props-no-spreading
    {...restIconProps}
    />

    1. Pass useSkeletonLoader prop to CardFeedIcon in WorkspaceCompanyCardsTable/index.tsx when creating the icon for the table

    <CardFeedIcon
    key={feedName}
    iconProps={{
    height: variables.cardIconHeight,
    width: variables.cardIconWidth,
    additionalStyles: styles.cardIcon,
    }}
    selectedFeed={feedName}
    />

    Minor styling of the loading indicator / skeleton can be finalized during the PR phase

    POC.mp4

    What alternative solutions did you explore? (Optional)

    NA

  5. daledah commented on Dec 30, 2025

    @daledah
    Contributor

    Proposal

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

    The unassigned card gets removed optimistically.

    What is the root cause of that problem?

    we set cardID as null here that will remove the card in UI

    optimisticData: [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bankName}`,
    value: {
    [cardID]: null,
    },
    },

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

    1. We should set the pendingAction as delete in optimistic data then reset it in failure data and success data
                {
                    onyxMethod: Onyx.METHOD.MERGE,
                    key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bankName}`,
                    value: {
                        [cardID]: {
                            ...card,
                            pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
                        },
                    },
                },
    

    optimisticData: [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${domainOrWorkspaceAccountID}_${bankName}`,
    value: {
    [cardID]: null,
    },
    },

    1. Because we don't set cardID value as null so if the user navigate to the card detail page by URL, it still shows the full access and the user can unassign card again. So we need to disable it or we can show the not found page when card is pending delete
    bug.mov
        const isCardPendingDelete = card?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
        ...
        <MenuItemWithTopDescription
            description={translate('workspace.moreFeatures.companyCards.cardName')}
            disabled={isCardPendingDelete}
            onPress={() => Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARD_EDIT_CARD_NAME.getRoute(policyID, cardID, feedName))}
        />
        ...
        <MenuItem
            icon={expensifyIcons.RemoveMembers}
            title={translate('workspace.moreFeatures.companyCards.unassignCard')}
            style={styles.mb1}
            disabled={isCardPendingDelete}
            onPress={() => setIsUnassignModalVisible(true)}
        />
    

    Note: We should do the same with other places and other logic that will need to check if card is not pending delete

    What alternative solutions did you explore? (Optional)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  6. m-natarajan commented on Dec 30, 2025

    @m-natarajan

    Discussed about this issue here

  7. melvin-bot commented on Jan 3, 2026

    @melvin-bot

    @carlosmiceli, @dannymcclain, @zanyrenney, @dylanexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  8. dylanexpensify commented on Jan 5, 2026

    @dylanexpensify
    Contributor

    I think we should follow the same patter -> showing grey + strike through, then actioned when back online

  9. 43 remaining items

  10. added and removed
    Weekly
    on Feb 13, 2026
  11. melvin-bot commented on Feb 13, 2026

    @melvin-bot

    This issue has not been updated in over 15 days. @carlosmiceli, @dannymcclain, @hungvu193, @zanyrenney, @dylanexpensify, @ryntgh eroding to Monthly issue.

    P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

  12. hungvu193 commented on Feb 16, 2026

    @hungvu193
    Contributor

    Oh this is due for payment

  13. hungvu193 commented on Feb 16, 2026

    @hungvu193
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: This is a known issue that came from Tgolen fix transition #78078. We decided to fix it as a follow up here.

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: N/A

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    Regression Test Proposal

    Precondition:

    • Your workspace has at least one company card.

    Test:

    1. Go to workspace > Company card.
    2. Choose any card > Assign.
    3. Go Offline
    4. Click on that card > Unassign a card.
    5. Verify that the unassigned card gets shown as strike through or greyed out signaling a pending action like in the other pages for offline behavior.

    Do we agree 👍 or 👎

  14. dylanexpensify commented on Feb 16, 2026

    @dylanexpensify
    Contributor

    Payment summary:

    Contributor: @ryntgh $250 via Upwork
    Contributor+: @hungvu193 $250 via NewDot

    Please apply/request!

  15. ryntgh commented on Feb 16, 2026

    @ryntgh
    Contributor

    Hi @dylanexpensify, I can't apply to the upwork job since the job is no longer available

  16. dylanexpensify commented on Feb 16, 2026

    @dylanexpensify
    Contributor
  17. ryntgh commented on Feb 16, 2026

    @ryntgh
    Contributor

    Thanks! I applied to the job

  18. dylanexpensify commented on Feb 17, 2026

    @dylanexpensify
    Contributor

    @ryntgh offer sent!

  19. dylanexpensify commented on Feb 17, 2026

    @dylanexpensify
    Contributor

    done

  20. dominictb commented on May 5, 2026

    @dominictb
    Contributor

    @hungvu193 Did you request payment here?

  21. hungvu193 commented on May 5, 2026

    @hungvu193
    Contributor

    @dominictb Thanks for asking. I think I did 😅 , I've just checked my ND transactions and it was approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugExternalMonthlyReviewing

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions