Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[$250] Expensify card - Failed to send magic code error is shown when trying to issue card multiple times #57243

Open
4 of 8 tasks
vincdargento opened this issue Feb 21, 2025 · 4 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@vincdargento
Copy link

vincdargento commented Feb 21, 2025

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: V9.1.3-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Yes, reproducible on both
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Device used: Redmi note 10s android 13
App Component: Other

Action Performed:

  1. Launch app
  2. Go to workspace settings - more features - enable Expensify card
  3. Add VBA and verify it
  4. Tap add card and issue card 4-5 times

Expected Result:

Failed to send magic code error must not be shown when trying to issue card

Actual Result:

After issuing card 4 times, unable to issue card 5th time. Failed to send a new magic code error is shown when trying to issue card after 4 or 5 times

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

bug.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021892968947976081615
  • Upwork Job ID: 1892968947976081615
  • Last Price Increase: 2025-02-21
Issue OwnerCurrent Issue Owner: @jayeshmangwani
@vincdargento vincdargento added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Feb 21, 2025
Copy link

melvin-bot bot commented Feb 21, 2025

Triggered auto assignment to @OfstadC (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.

@OfstadC OfstadC added the External Added to denote the issue can be worked on by a contributor label Feb 21, 2025
@melvin-bot melvin-bot bot changed the title Expensify card - Failed to send magic code error is shown when trying to issue card multiple times [$250] Expensify card - Failed to send magic code error is shown when trying to issue card multiple times Feb 21, 2025
Copy link

melvin-bot bot commented Feb 21, 2025

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Feb 21, 2025
Copy link

melvin-bot bot commented Feb 21, 2025

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

@FitseTLT
Copy link
Contributor

FitseTLT commented Feb 21, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-02-21 16:31:12 UTC.

Proposal

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

Expensify card - Failed to send magic code error is shown when trying to issue card multiple times

What is the root cause of that problem?

When pressing issue card we open the validation code modal here

onSubmit={() => setIsValidateCodeActionModalVisible(true)}

then we requestValidateCodeAction here when the modal opens
if (!firstRenderRef.current || !isVisible || hasMagicCodeBeenSent) {
return;
}
firstRenderRef.current = false;
sendValidateCode();
// We only want to send validate code on first render not on change of hasMagicCodeBeenSent, so we don't add it as a dependency.

But the problem is requestValidateCodeAction is a generic function that we use in many places to send RESEND_VALIDATE_CODE API request for the BE with no param
API.write(WRITE_COMMANDS.RESEND_VALIDATE_CODE, null, {optimisticData, successData, failureData});

But the BE has its internal way of rejecting repeated RESEND_VALIDATE_CODE requests done in a short period of time. So even if the user is assigning cards to different users in a short period of time what the BE understands it is making repeated RESEND_VALIDATE_CODE requests in short period of time so it returns error

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

This is both BE and FE issue we still need to deny repeated RESEND_VALIDATE_CODE requests in short period of time but may be if it for the same purpose/same flow. So from FE we need to start sending params for RESEND_VALIDATE_CODE API that identifies what we are trying to perform then the BE will only deny repeated RESEND_VALIDATE_CODE requests if it is for performing the same action.
For instance in this specific case we can identify an operation with policyID, the member the card is being issued or other params to identify the operation and we will send the identifying code to the BE so that the BE will only deny repeated requests if made for the same operation. We can alternatively generate a unique code in the start of the process startIssueNewCardFlow and save it in onyx and then send that code as a param to the BE.
BTW this fix should be applied for all other cases we need a validation code/requestValidateCodeAction to finish flows.

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

N / A

What alternative solutions did you explore? (Optional)

BE solution can also be applied where this denying of repeated requests should be reset when a user makes a successful verification by entering a correct magic code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

4 participants