Skip to content

[$500] Web – Assign Task - An error occurs when both User A and User B press the "Mark as done" button simultaneously #27570

Closed

Description

@lanitochka17

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. Open any chat labeled "Assign Task" between User A and User B. (The task was created by User A.)
  2. Click "Mark as done" and "Mark as incomplete" from User A. Observe that it works correctly
  3. Click "Mark as done" and "Mark as incomplete" from User B. Observe that it also works correctly
  4. Ensure that the "Mark as done" option is present in the header for each user
  5. Simultaneously press the "Mark as done" button from both User A and User B
  6. An error message appears on User B's system, stating, "You do not have permission to perform the requested action.

Expected Result:

The error should not appear and the task should be closed regardless of which user performs the action

Actual Result:

An error message appears on User B's system, stating, "You do not have permission to perform the requested action."

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.70-5

Reproducible in staging?: Yes

Reproducible in production?: Yes

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

Bug.2.mp4
0-02-01-6ce24cc1ebb53856f7b92b9ede59b4d4774dbe3451ed70704747a1e8a05c7c25_bdeb7f22536b3c99.1.mp4

Expensify/Expensify Issue URL:

Issue reported by: @usmantariq96

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1694588501046099

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0129a7b3f4233c245f
  • Upwork Job ID: 1702820221863018496
  • Last Price Increase: 2023-10-06
  • Automatic offers:
    • dukenv0307 | Contributor | 27120400

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 15, 2023
  2. changed the title [-]Web – Assign Task - An error occurs when both User A and User B press the "Mark as done" button simultaneously[/-] [+][$500] Web – Assign Task - An error occurs when both User A and User B press the "Mark as done" button simultaneously[/+] on Sep 15, 2023
  3. melvin-bot commented on Sep 15, 2023

    @melvin-bot
  4. melvin-bot commented on Sep 15, 2023

    @melvin-bot

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

  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Sep 15, 2023
  6. melvin-bot commented on Sep 15, 2023

    @melvin-bot

    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
  7. melvin-bot commented on Sep 15, 2023

    @melvin-bot

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

  8. melvin-bot commented on Sep 15, 2023

    @melvin-bot

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

  9. dukenv0307 commented on Sep 16, 2023

    @dukenv0307
    Contributor

    Proposal

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

    An error message appears on User B's system, stating, "You do not have permission to perform the requested action."

    What is the root cause of that problem?

    At the time the CompleteTask API call from user B is made, the report is already in the completed state, so it throws an error.

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

    We can check if the report action is CompleteTask, and the report is already in the completed state, then we clear the report action errors.

    We can do it in an useEffect in ReportActionItem (or somewhere like ReportActionsList we can loop through the actions). This will create a graceful experience if in a team, multiple members complete a task at the same time (or in offline mode then comes online).

    useEffect(() => {
            if (props.action.actionName === CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED 
              && !_.isEmpty(props.action.errors) 
              && props.report.stateNum === CONST.REPORT.STATE_NUM.SUBMITTED 
              && props.report.statusNum === CONST.REPORT.STATUS.APPROVED) {            
                ReportActions.clearReportActionErrors(props.report.reportID, props.action)
            }
    }, [props]);
    

    It can be fixed the same for the reopen/cancel case.

    What alternative solutions did you explore? (Optional)

    An alternative is to add a field in the back-end to clarify that the error is due to task is already completed, like errorCode: 'taskAlreadyCompleted', and clear the error right away if the report action is TASKCOMPLETED and it has that error code. Or we can depend on the 403 http status from the back-end.

  10. ayazalavi commented on Sep 16, 2023

    @ayazalavi
    Contributor

    Proposal

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

    In assign task when 2 users simulatenously complete task then 1 of 2 users gets an unwanted error.

    What is the root cause of that problem?

    Root cause is that we are hard coding error message like here:

    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${taskReportID}`,
    value: {
    [completedTaskReportAction.reportActionID]: {
    errors: ErrorUtils.getMicroSecondOnyxError('task.messages.error'),
    },
    },
    },

    Same is true for both completeTask and reopenTask methods.

    This is not considering other reasons of error and have just 1 hard coded case of permissions issue which is not true in this specific case.

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

    We need to add error handling for task errors and show error that is tailored to the problem that happened which in this case is e.g. "User 1 has already completed task.", "User 2 has already reopened task" or simply "Unable to complete/reopen task".

    In following piece of code

    App/src/languages/en.ts

    Lines 1524 to 1539 in 76c1559

    task: {
    task: 'Task',
    title: 'Title',
    description: 'Description',
    assignee: 'Assignee',
    completed: 'Completed',
    messages: {
    completed: 'completed task',
    canceled: 'canceled task',
    reopened: 'reopened task',
    error: 'You do not have the permission to do the requested action.',
    },
    markAsDone: 'Mark as done',
    markAsIncomplete: 'Mark as incomplete',
    assigneeError: 'There was an error assigning this task, please try another assignee.',
    },

    we need to add 2 more keys

    1. completingError: "Unable to mark the task as completed. Please try again later."
    2. reopeningError: "Unable to reopen the task. Please try again later."

    then in completeTask method use task.completingError instead of task.messages.error

    errors: ErrorUtils.getMicroSecondOnyxError('task.messages.error'),

    and in reopenTask use task.reopeningError instead of task.messages.error

    errors: ErrorUtils.getMicroSecondOnyxError('task.messages.error'),

    Result:

    Untitled.9.mp4

    What alternative solutions did you explore? (Optional)

    Just simply remove this:

    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${taskReportID}`,
    value: {
    [completedTaskReportAction.reportActionID]: {
    errors: ErrorUtils.getMicroSecondOnyxError('task.messages.error'),
    },
    },
    },

    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${taskReportID}`,
    value: {
    [reopenedTaskReportAction.reportActionID]: {
    errors: ErrorUtils.getMicroSecondOnyxError('task.messages.error'),
    },
    },
    },

    That will stop showing error messages for tasks api call.

  11. 85 remaining items

  12. rlinoz commented on Nov 27, 2023

    @rlinoz
    Contributor

    I think we can close this issue, but I am not sure whether payment is due or not.

    @MitchExpensify

  13. MitchExpensify commented on Nov 28, 2023

    @MitchExpensify
    Contributor

    Payment summary:

  14. sobitneupane commented on Nov 29, 2023

    @sobitneupane
    Contributor

    @MitchExpensify A proposal was selected and while implementing the PR, it was decided that the issue would be best solved on the backend. So, we ended of closing the PR without merging.

  15. dukenv0307 commented on Nov 29, 2023

    @dukenv0307
    Contributor

    Should we process payment for both C and C+ since we spent lots of effort in the PR and it's almost done. We have the same case in the past #17188 (comment)

  16. MitchExpensify commented on Dec 5, 2023

    @MitchExpensify
    Contributor

    That seems fair, can you both please apply to this job for payment? https://www.upwork.com/jobs/~01314f533571a41c4f

  17. MitchExpensify commented on Dec 5, 2023

    @MitchExpensify
    Contributor

    And same for you usmantariq96, thanks!

  18. usmantariq96 commented on Dec 6, 2023

    @usmantariq96

    @MitchExpensify applied for the job
    thanks

  19. dukenv0307 commented on Dec 6, 2023

    @dukenv0307
    Contributor

    That seems fair, can you both please apply to this job for payment? https://www.upwork.com/jobs/~01314f533571a41c4f

    @MitchExpensify applied, thank you!

  20. sobitneupane commented on Dec 8, 2023

    @sobitneupane
    Contributor

    @MitchExpensify I will request payment on newDot once you post the payment summary.

  21. MitchExpensify commented on Dec 11, 2023

    @MitchExpensify
    Contributor

    Updated the payment summary - #27570 (comment)

  22. MitchExpensify commented on Dec 11, 2023

    @MitchExpensify
    Contributor

    Do we need to add a regression test here @sobitneupane ?

  23. sobitneupane commented on Dec 15, 2023

    @sobitneupane
    Contributor

    Regression Test Proposal

    1. Create a task from User A assigning it to User B.
    2. Ensure that the "Mark as done" option is present in the header for each user
    3. Simultaneously press the "Mark as done" button from both User A and User B
    4. Verify that the app works fine and no error is displayed
    5. Ensure that the task is marked as Done
    6. Simultaneously press the green box to re-open the task from both User A and User B
    7. Verify that the app works fine and no error is displayed
    8. Simultaneously press Cancel the task from both User A and User B
    9. Verify that the app works fine and no error is displayed

    Do we agree 👍 or 👎

  24. sobitneupane commented on Dec 15, 2023

    @sobitneupane
    Contributor

    #27570 (comment)

    Requested payment on newDot.

  25. JmillsExpensify commented on Dec 15, 2023

    @JmillsExpensify
    Contributor

    $500 payment approved for @sobitneupane based on this comment.

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.EngineeringInternalRequires API changes or must be handled by Expensify staffMonthlyKSv2ReviewingHas a PR in review

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions