[$250] Company Cards - Unable to remove card feed that's under review
If you havenβt already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Version Number: 9.0.56-2 Reproducible in staging?: Y Reproducible in production?: No, unable to check If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: N/A Issue reported by: Applause - Internal Team
Issue found when executing PR https://github.com/Expensify/App/pull/51569
Action Performed:
- Open the app
- Log in with a new expensifail account
- Create a workspace
- Navigate to Workspace settings - More features
- Enable "Company cards"
- Navigate to Workspace settings - Company cards
- Navigate to Add company cards - American Express - American Express Corporate Cards - Next
- Input any name and tap on the "Next" button
- Tap on the "Submit" button
- Tap on the "Settings" button
- Tap on the "Remove card feed" button
- Tap on the "Delete" button
Expected Result:
I should be able to delete the feed
Actual Result:
Unable to remove card feed that's under review. "Import company cards" page can be seen briefly but the "review" page loads again
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
- [ ] Android: Standalone
- [ ] Android: HybridApp
- [ ] Android: mWeb Chrome
- [x] iOS: Standalone
- [x] iOS: HybridApp
- [ ] iOS: mWeb Safari
- [x] MacOS: Chrome / Safari
- [ ] MacOS: Desktop
Screenshots/Videos
Add any screenshot/video evidence
https://github.com/user-attachments/assets/35c3a695-b946-40a1-9565-b7be9e43a166
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~021852426699884185074
- Upwork Job ID: 1852426699884185074
- Last Price Increase: 2024-11-01
Issue Owner
Current Issue Owner: @getusha
Triggered auto assignment to @marcochavezf (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.
π¬ A slack conversation has been started in #expensify-open-source
:wave: Friendly reminder that deploy blockers are time-sensitive β± issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
- Identify the pull request that introduced this issue and revert it.
- Find someone who can quickly fix the issue.
- Fix the issue yourself.
We think that this bug might be related to #wave-collect - Release 2
This is happening in production, so not a blocker
https://github.com/user-attachments/assets/b4df5312-ce91-40a2-99d3-2c3f5694ae7a
Job added to Upwork: https://www.upwork.com/jobs/~021852426699884185074
Triggered auto assignment to Contributor-plus team member for initial proposal review - @getusha (External)
Triggered auto assignment to @lschurr (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.
Proposal
Please re-state the problem that we are trying to solve in this issue.
- Unable to remove card feed that's under review. "Import company cards" page can be seen briefly but the "review" page loads again
What is the root cause of that problem?
-
When calling
RemoveFeedAPI, we always assume that it is removed successfully by setting the optimistic data: https://github.com/Expensify/App/blob/bef062b4caa7f665159dc107911e708031e648c4/src/libs/actions/CompanyCards.ts#L136-L143 and we always navigate back right after call that API: https://github.com/Expensify/App/blob/bef062b4caa7f665159dc107911e708031e648c4/src/pages/workspace/companyCards/WorkspaceCompanyCardsSettingsPage.tsx#L51-L55 -
As a result, if the API is not called successfully, the "Import company cards" page can be seen briefly but the "review" page loads again as mentioned in the actual result in OP.
What changes do you think we should make in order to solve the problem?
- We need to make sure the RHP (company card setting page) is only closed when the API is called successfully. Otherwise, it needs display the error message. It is the same as what we did when issue a new card.
Step 1: Update the onyxData:
const onyxData: OnyxData = {
optimisticData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`,
value: {
settings: {
companyCards: {
[bankName]: {
isLoading: true,
},
},
},
},
},
],
successData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`,
value: {
settings: {
companyCards: {
[bankName]: {
isLoading: false,
},
},
},
},
},
],
failureData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`,
value: {
settings: {
companyCards: {
[bankName]: {
isLoading: false,
errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'),
},
},
},
},
},
],
};
Step 2: Add a logic to this position so that it only closes the RHN once the API is called successfully:
const {isOffline} = useNetwork();
const isRemovedSuccessfully = cardFeeds?.settings?.companyCards?.[selectedFeed]?.isLoading === false && cardFeeds?.settings?.companyCards?.[selectedFeed].errors === undefined;
const isRemoving = cardFeeds?.settings?.companyCards?.[selectedFeed]?.isLoading === true;
const errorMessage = ErrorUtils.getLatestErrorMessage(cardFeeds?.settings?.companyCards?.[selectedFeed]);
const preIsRemovedSuccessfully = usePrevious(isRemovedSuccessfully);
useEffect(() => {
if (!preIsRemovedSuccessfully && isRemovedSuccessfully) {
Navigation.setNavigationActionToMicrotaskQueue(Navigation.goBack);
}
}, [isRemovedSuccessfully, preIsRemovedSuccessfully]);
Step 3: Update button so that it will display the error message if has:
<MenuItem
icon={Expensicons.Trashcan}
title={translate('workspace.moreFeatures.companyCards.removeCardFeed')}
onPress={() => setDeleteCompanyCardConfirmModalVisible(true)}
disabled={isOffline || isRemoving}
errorText={errorMessage}
/>
What alternative solutions did you explore? (Optional)
π£ @allgandalf π An offer has been automatically sent to your Upwork account for the Contributor role π Thanks for contributing to the Expensify app!
Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review π§βπ» Keep in mind: Code of Conduct | Contributing π
@marcochavezf happy to take this one over as I have been working on the workspace feeds feature
@mountiny should i review the existing proposal or is CS gonna implement this ?
I think we can go with the contributors here
@daledah what does the API return in the current state ? can you attach an screenshot of it ? We fallback to the previous state when the request fails
@allgandalf Here is the BE's response.
@daledah in your RCA can. you please include why this response is 404
As a result, if the API is not called successfully,
But in the networks tabs we see the API called π€
But in the networks tabs we see the API called π€
Ah, I mean the API is called with an error
@mountiny Could you help check when BE returns this error?
Working on this one in a similar issue. https://github.com/Expensify/App/issues/52252
@mountiny should we hold this for https://github.com/Expensify/App/issues/52252 (BE) one ?
Yep, working on that one today
PR is up https://github.com/Expensify/Auth/pull/13111
There is a follow up merged so we can test again shortly
@lschurr, @mountiny, @allgandalf Whoops! This issue is 2 days overdue. Let's get this updated quick!
I believe @joekaufmanexpensify tested removing the pending card so this worked well