You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$500] Web – Assign Task - An error occurs when both User A and User B press the "Mark as done" button simultaneously #27570
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
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).
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.
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".
@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.
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)
Activity
[-]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[/+]melvin-bot commentedon Sep 15, 2023
Job added to Upwork: https://www.upwork.com/jobs/~0129a7b3f4233c245f
melvin-bot commentedon Sep 15, 2023
Triggered auto assignment to @michaelhaxhiu (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Sep 15, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)melvin-bot commentedon Sep 15, 2023
Triggered auto assignment to @sakluger (
External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.melvin-bot commentedon Sep 15, 2023
Triggered auto assignment to Contributor-plus team member for initial proposal review - @sobitneupane (
External)dukenv0307 commentedon Sep 16, 2023
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
CompleteTaskAPI call from user B is made, the report is already in thecompletedstate, 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
useEffectinReportActionItem(or somewhere likeReportActionsListwe 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).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 isTASKCOMPLETEDand it has that error code. Or we can depend on the403http status from the back-end.ayazalavi commentedon Sep 16, 2023
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:
App/src/libs/actions/Task.js
Lines 264 to 272 in 76c1559
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
we need to add 2 more keys
then in completeTask method use task.completingError instead of task.messages.error
App/src/libs/actions/Task.js
Line 269 in 76c1559
and in reopenTask use task.reopeningError instead of task.messages.error
App/src/libs/actions/Task.js
Line 356 in 76c1559
Result:
Untitled.9.mp4
What alternative solutions did you explore? (Optional)
Just simply remove this:
App/src/libs/actions/Task.js
Lines 264 to 272 in 76c1559
App/src/libs/actions/Task.js
Lines 351 to 359 in 76c1559
That will stop showing error messages for tasks api call.
85 remaining items
rlinoz commentedon Nov 27, 2023
I think we can close this issue, but I am not sure whether payment is due or not.
@MitchExpensify
MitchExpensify commentedon Nov 28, 2023
Payment summary:
sobitneupane commentedon Nov 29, 2023
@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.
dukenv0307 commentedon Nov 29, 2023
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)
MitchExpensify commentedon Dec 5, 2023
That seems fair, can you both please apply to this job for payment? https://www.upwork.com/jobs/~01314f533571a41c4f
MitchExpensify commentedon Dec 5, 2023
And same for you usmantariq96, thanks!
usmantariq96 commentedon Dec 6, 2023
@MitchExpensify applied for the job
thanks
dukenv0307 commentedon Dec 6, 2023
@MitchExpensify applied, thank you!
sobitneupane commentedon Dec 8, 2023
@MitchExpensify I will request payment on newDot once you post the payment summary.
MitchExpensify commentedon Dec 11, 2023
Updated the payment summary - #27570 (comment)
MitchExpensify commentedon Dec 11, 2023
Do we need to add a regression test here @sobitneupane ?
sobitneupane commentedon Dec 15, 2023
Regression Test Proposal
Do we agree 👍 or 👎
sobitneupane commentedon Dec 15, 2023
#27570 (comment)
Requested payment on newDot.
JmillsExpensify commentedon Dec 15, 2023
$500 payment approved for @sobitneupane based on this comment.