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

[HOLD for payment 2023-10-16] [HOLD for payment 2023-10-13] [$500] LOW: Web - Clicking on "Replace" for a paid scan request results in the scan modal opening and then closing automatically #27965

Closed
6 tasks
kbecciv opened this issue Sep 21, 2023 · 55 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@kbecciv
Copy link

kbecciv commented Sep 21, 2023

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


Action Performed:

  1. Log in with User A.
  2. Open a chat with User B.
  3. Go to the "Request money" section and select "Scan."
  4. Send a scanned image.
  5. Click on the sent image and go to its details.
  6. Go to User B's account.
  7. Click on "Pay elsewhere."
  8. Return to User A's account.
  9. Click on the scanned image and attempt to replace it

Expected Result:

When clicking on "Replace" for a paid scan request, the scan modal should either remain open or not open at all, depending on the intended functionality

Actual Result:

Clicking on "Replace" for a paid scan request causes the scan modal to open briefly and then close automatically

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.72.8
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation

screen-recording-2023-09-20-at-22122-pm_sWMvL9a8.mp4
Recording.4676.mp4

Expensify/Expensify Issue URL:
Issue reported by: @ayazhussain79
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1695202167946769

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0106bd3efbb87edef7
  • Upwork Job ID: 1704962599505321984
  • Last Price Increase: 2023-09-21
  • Automatic offers:
    • dukenv0307 | Contributor | 26918886
@kbecciv kbecciv added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 21, 2023
@melvin-bot melvin-bot bot changed the title Web - Clicking on "Replace" for a paid scan request results in the scan modal opening and then closing automatically [$500] Web - Clicking on "Replace" for a paid scan request results in the scan modal opening and then closing automatically Sep 21, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 21, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 21, 2023

Triggered auto assignment to @puneetlath (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

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

melvin-bot bot commented Sep 21, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@melvin-bot
Copy link

melvin-bot bot commented Sep 21, 2023

Triggered auto assignment to @NicMendonca (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Sep 21, 2023

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

@neonbhai
Copy link
Contributor

neonbhai commented Sep 21, 2023

Proposal

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

Clicking on "Replace" for a paid scan request results in the scan modal opening and then closing automatically

What is the root cause of that problem?

This happens because in AttachmentModal.js we allow the user to navigate to the edit request route without checks.

The menuItem does not have any checks:

threeDotsMenuItems={[
{
icon: Expensicons.Camera,
text: props.translate('common.replace'),
onSelected: () => {
onModalHideCallbackRef.current = () => Navigation.navigate(ROUTES.getEditRequestRoute(props.report.reportID, CONST.EDIT_REQUEST_FIELD.RECEIPT));
closeModal();
},
},

This results in navigating to EditRequestPage.js

here if canEdit for this request is false, this useEffect dismisses the modal:

useEffect(() => {
if (canEdit) {
return;
}
Navigation.isNavigationReady().then(() => {
Navigation.dismissModal();
});
}, [canEdit]);

This causes the flash.

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

  • Solution 1:

    We can show a message that says that we are not allowed to edit this when editRequest page is accessed without the permission to edit.
    Since EditPage is a core page, it can be accessed via many places.
    The opening and quickly dismissing the modal is programmed into the page itself, that we should fix. Instead of dismissing the Page, we can inform the user that this action is not allowed.
    We can accomplish this by:
    • Showing a Modal:

      This is how it would look like:
Screencast.from.22-09-23.07.38.47.AM.IST.webm
  • Showing a Page

    • Another way would be to create a FullPageActionNotAllowed component that will inform the user that "this action is not allowed":
Screencast.from.22-09-23.07.50.41.AM.IST.webm

This would also be better UX as when accessed from other paths, instead of just dismissing a clear message is shown.

  • Solution 2:

    We will also remove the menuItem if the report is Settled.

    This can be done by adding a check for settled Iou to the menuItem here:

    threeDotsMenuItems={[
    {
    icon: Expensicons.Camera,
    text: props.translate('common.replace'),
    onSelected: () => {
    onModalHideCallbackRef.current = () => Navigation.navigate(ROUTES.getEditRequestRoute(props.report.reportID, CONST.EDIT_REQUEST_FIELD.RECEIPT));
    closeModal();
    },
    },

     const parentReport = ReportUtils.getParentReport(props.report);
     const parentReportAction = ReportActionsUtils.getParentReportAction(report);
     const isSettled = ReportUtils.isSettled(parentReport.reportID);
     const isDeleted = ReportUtils.isDeleted(parentReportAction.reportID);
     const isRequestor = ReportUtils.isMoneyRequestReport(parentReport) && lodashGet(session, 'accountID', null) === parentReportAction.actorAccountID;
     // now we have all the info:
     const canReplace = !isSettled && !isDeleted && isRequestor;

    We can then use canReplace to conditionally Render the menuItem here
    Note: We will restructure code to not make these library calls if the Attachment Modal is not a receipt

What alternative solutions did you explore? (Optional)

xx

@huzaima
Copy link

huzaima commented Sep 21, 2023

Proposal

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

When clicking on "Replace" for a paid request, the modal should not show the "Replace" option.

What is the root cause of that problem?

The settled report cannot be edited. It's checked here:

useEffect(() => {
if (canEdit) {
return;
}
Navigation.isNavigationReady().then(() => {
Navigation.dismissModal();
});
}, [canEdit]);

Now in AttachmentModal.js, we don't check if the request was settled and unconditionally redirect to EditRequestPage.

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

We should check if the request was settled and shouldn't show the "Replace" menu item if it's settled. In AttachmentModal.js, we should check if the parentReport is settled. It's important to check parentReport. If we do ReportUtils.isSettled(props.report.reportID), it will be incorrect. We should first get the parent report like this:

const parentReport = ReportUtils.getParentReport(props.report);

and then check ReportUtils.isSettled(parentReport.reportID).

@melvin-bot
Copy link

melvin-bot bot commented Sep 21, 2023

📣 @huzaima! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@melvin-bot
Copy link

melvin-bot bot commented Sep 21, 2023

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@dukenv0307
Copy link
Contributor

dukenv0307 commented Sep 22, 2023

Proposal

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

replace image option appears even after paid

What is the root cause of that problem?

We always set threeDotsMenuItems as two options for receipt request without checking the request is paid or not

threeDotsMenuItems={[
{
icon: Expensicons.Camera,
text: props.translate('common.replace'),
onSelected: () => {
onModalHideCallbackRef.current = () => Navigation.navigate(ROUTES.getEditRequestRoute(props.report.reportID, CONST.EDIT_REQUEST_FIELD.RECEIPT));
closeModal();
},
},
{

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

We should check if the request cannot edit, we will remove replace option from threeDotsMenuItems.
The check for cannot edit we can do the same thing in EditRequestPage

  1. We should subscribe parentReport, policy, parentReportActions of the report from Onyx. This will be helpful in making the three-dot update dynamically when the request is paid while the three-dot menu is being opened.

  2. Create a useMemo to set the three-dot menu items

const threeDotsMenuItems = useMemo(() => {
  if (!isAttachmentReceipt || !props.parentReport || !props.parentReportActions) {
      return [];
  }
  let menuItems = [];
  const parentReportAction = props.parentReportActions[props.report.parentReportActionID];
  const isDeleted = ReportActionsUtils.isDeletedAction(parentReportAction);
  const isSettled = ReportUtils.isSettled(props.parentReport.reportID);

  const isAdmin = Policy.isAdminOfFreePolicy([props.policy]) && ReportUtils.isExpenseReport(props.parentReport);
  const isRequestor = ReportUtils.isMoneyRequestReport(props.parentReport) && lodashGet(props.session, 'accountID', null) === parentReportAction.actorAccountID;
  const canEdit = !isSettled && !isDeleted && (isAdmin || isRequestor);
  if (canEdit) {
      menuItems.push({
          icon: Expensicons.Camera,
          text: props.translate('common.replace'),
          onSelected: () => {
              onModalHideCallbackRef.current = () => Navigation.navigate(ROUTES.getEditRequestRoute(props.report.reportID, CONST.EDIT_REQUEST_FIELD.RECEIPT));
              closeModal();
          },
      })
  }
  menuItems.push({
      icon: Expensicons.Download,
      text: props.translate('common.download'),
      onSelected: () => downloadAttachment(source),
  })
  return menuItems;
}, [isAttachmentReceipt, props.parentReport, props.parentReportActions, props.policy])
  1. Set it to threeDotsMenuItems props
threeDotsMenuItems={threeDotsMenuItems}

threeDotsMenuItems={[

What alternative solutions did you explore? (Optional)

NA

Result

Screencast.from.21-09-2023.16.34.49.webm

@ashanSpeiris

This comment was marked as off-topic.

@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@dylanexpensify
Copy link
Contributor

taking over for Puneet as it's part of wave4!

@dylanexpensify
Copy link
Contributor

@burczu lets get these proposals reviewed soon! 🙏

@melvin-bot melvin-bot bot added the Overdue label Sep 25, 2023
@dylanexpensify
Copy link
Contributor

@burczu let's get this done today!

@melvin-bot melvin-bot bot removed the Overdue label Sep 25, 2023
@burczu
Copy link
Contributor

burczu commented Sep 25, 2023

@dylanexpensify yes, I'm on it right now actually

@burczu
Copy link
Contributor

burczu commented Sep 25, 2023

I've just reviewed all the proposals and I believe that all of them recognized the root case correctly. In my opinion removing the Replace option from the three dot menu when it's impossible to replace the receipt is the best from the UX point of view.

The proposal from @dukenv0307 presents the solution in the most comprehensive way - I like it the most and would recommend proceeding with it.

However the proposall from @neonbhai (Solution 2) is very similar (but not described that well) and it's hard to tell who was first here - I've checked the editing history and it seems the detailed explanation was added after @dukenv0307.

So, whoever will review these proposals after me, please take it into consideration when making the final decision.

🎀 👀 🎀 C+ reviewed

@melvin-bot melvin-bot bot added the Awaiting Payment Auto-added when associated PR is deployed to production label Oct 6, 2023
@melvin-bot melvin-bot bot changed the title [$500] Web - Clicking on "Replace" for a paid scan request results in the scan modal opening and then closing automatically [HOLD for payment 2023-10-13] [$500] Web - Clicking on "Replace" for a paid scan request results in the scan modal opening and then closing automatically Oct 6, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 6, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 6, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot
Copy link

melvin-bot bot commented Oct 6, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.78-4 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-10-13. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

For reference, here are some details about the assignees on this issue:

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Oct 6, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@burczu] The PR that introduced the bug has been identified. Link to the PR:
  • [@burczu] 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:
  • [@burczu] A discussion in #expensify-bugs 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:
  • [@burczu] Determine if we should create a regression test for this bug.
  • [@burczu] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@dylanexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Oct 9, 2023
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2023-10-13] [$500] Web - Clicking on "Replace" for a paid scan request results in the scan modal opening and then closing automatically [HOLD for payment 2023-10-16] [HOLD for payment 2023-10-13] [$500] Web - Clicking on "Replace" for a paid scan request results in the scan modal opening and then closing automatically Oct 9, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 9, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.79-5 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-10-16. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

For reference, here are some details about the assignees on this issue:

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Oct 9, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@burczu] The PR that introduced the bug has been identified. Link to the PR:
  • [@burczu] 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:
  • [@burczu] A discussion in #expensify-bugs 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:
  • [@burczu] Determine if we should create a regression test for this bug.
  • [@burczu] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@dylanexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@dylanexpensify
Copy link
Contributor

dylanexpensify commented Oct 10, 2023

Payment summary:

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Oct 12, 2023
@dylanexpensify
Copy link
Contributor

reviewing today!

@melvin-bot melvin-bot bot removed the Overdue label Oct 16, 2023
@burczu
Copy link
Contributor

burczu commented Oct 17, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@burczu] The PR that introduced the bug has been identified. Link to the PR: This is not regression imo, this situation just wasn't handled before.
  • [@burczu] 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: n/a
  • [@burczu] A discussion in #expensify-bugs 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
  • [@burczu] Determine if we should create a regression test for this bug.
  • [@burczu] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@dylanexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@dylanexpensify
Copy link
Contributor

payment upcoming!

@melvin-bot melvin-bot bot added the Overdue label Oct 20, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 23, 2023

@burczu, @Li357, @dylanexpensify, @dukenv0307 Huh... This is 4 days overdue. Who can take care of this?

@melvin-bot
Copy link

melvin-bot bot commented Oct 25, 2023

@burczu, @Li357, @dylanexpensify, @dukenv0307 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

@melvin-bot
Copy link

melvin-bot bot commented Oct 27, 2023

@burczu, @Li357, @dylanexpensify, @dukenv0307 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

@dylanexpensify dylanexpensify changed the title [HOLD for payment 2023-10-16] [HOLD for payment 2023-10-13] [$500] Web - Clicking on "Replace" for a paid scan request results in the scan modal opening and then closing automatically [HOLD for payment 2023-10-16] [HOLD for payment 2023-10-13] [$500] LOW: Web - Clicking on "Replace" for a paid scan request results in the scan modal opening and then closing automatically Oct 27, 2023
@dylanexpensify
Copy link
Contributor

@ayazhussain79 please apply to job for reporter payment!

@melvin-bot melvin-bot bot removed the Overdue label Oct 27, 2023
@ayazhussain79
Copy link
Contributor

@dylanexpensify applied on upwork, Thank you

@dylanexpensify
Copy link
Contributor

offer sent @ayazhussain79!

@dylanexpensify
Copy link
Contributor

done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
No open projects
Development

No branches or pull requests