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
[Due for payment 2025-02-28] [$250] Delete expene missing after cancel payment #55319
Version Number: 9.0.86-0 Reproducible in staging?: Y Reproducible in production?: Y If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: 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 Expensify/Expensify Issue URL: Issue reported by:@dukenv0307 Slack conversation (hyperlinked to channel name): expensify_bugs
Action Performed:
Create an expense
Go to offline
Click pay elsewhere
Click report header -> Cancel payment
Click report header again
Expected Result:
Delete expense button is missing
Actual Result:
Delete expense button is displayed
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Android: Standalone
Android: HybridApp
Android: mWeb Chrome
iOS: Standalone
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop
Screenshots/Videos
Add any screenshot/video evidencebug-resize.1.mp4Recording.891.mp4
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
What alternative solutions did you explore? (Optional)
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
🚨 Edited by proposal-police: This proposal was edited at 2025-01-16 06:50:00 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
There are 2 bugs in this flow:
Delete expene missing after cancel payment.
The optimistic message (next step) for policy with instant submit enabled is wrong ( doesn't match with what the backend returns)
What is the root cause of that problem?
When we cancel the payment, we set the statusNum to CONST.REPORT.STATUS_NUM.CLOSED when the policy approval mode is optional, this causes the bug in offline case where the delete and hold button are hidden. when we get api response from the BE, statusNum is correctly set to CONST.REPORT.STATUS_NUM.SUBMITTED.
Now, when we cancel payment, the next steps for a policy with no approval flow enabled is to pay for the expense again. but now we see that no action is required (Which changes again when we get the response from the BE api).
What changes do you think we should make in order to solve the problem?
We need to update the statusNum to CONST.REPORT.STATUS_NUM.SUBMITTEDhere:
Now we also need to update the nextSteps here, because with only the above change there will be a regression that we will always show that Waiting for (name) to approve expense(s). regardless of if the policy has approval flow enabled or not, only doing the change in 1. will cause this regression.
So we need to fix this one too, to do that we need to update the following case:
To display only when autoReportingFrequency !== CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT and for other cases we can directly show the waiting for payment message optimistically, we need to make changes as follows:
Details
--- a/src/libs/NextStepUtils.ts+++ b/src/libs/NextStepUtils.ts@@ -5,7 +5,7 @@ import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
-import type {Policy, Report, ReportNextStep} from '@src/types/onyx';+import type {Policy, Report, ReportNextStep, Session} from '@src/types/onyx';
import type {Message} from '@src/types/onyx/ReportNextStep';
import type DeepValueOf from '@src/types/utils/DeepValueOf';
import {getNextApproverAccountID} from './actions/IOU';
@@ -16,6 +16,7 @@ import * as ReportUtils from './ReportUtils';
let currentUserAccountID = -1;
let currentUserEmail = '';
+let session: Session;
Onyx.connect({
key: ONYXKEYS.SESSION,
callback: (value) => {
@@ -25,6 +26,7 @@ Onyx.connect({
currentUserAccountID = value?.accountID ?? -1;
currentUserEmail = value?.email ?? '';
+ session = value;
},
});
@@ -86,6 +88,7 @@ function buildNextStep(report: OnyxEntry<Report>, predictedNextStatus: ValueOf<t
}
const {policyID = '', ownerAccountID = -1} = report ?? {};
+ const isPayer = ReportUtils.isPayer(session, report);
const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`] ?? ({} as Policy);
const {harvesting, autoReportingOffset} = policy;
const autoReportingFrequency = PolicyUtils.getCorrectedAutoReportingFrequency(policy);
@@ -202,7 +205,10 @@ function buildNextStep(report: OnyxEntry<Report>, predictedNextStatus: ValueOf<t
optimisticNextStep = {
type,
icon: CONST.NEXT_STEP.ICONS.HOURGLASS,
- message: [+ };++ if (autoReportingFrequency !== CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT) {+ optimisticNextStep.message = [
{
text: 'Waiting for ',
},
@@ -219,8 +225,32 @@ function buildNextStep(report: OnyxEntry<Report>, predictedNextStatus: ValueOf<t
{
text: ' %expenses.',
},
- ],- };+ ];+ } else {+ optimisticNextStep.message = [+ {+ text: 'Waiting for ',+ },+ isPayer+ ? {+ text: `you`,+ type: 'strong',+ }+ : {+ text: `an admin`,+ type: 'strong',+ },+ {+ text: ' to ',+ },+ {+ text: 'pay',+ },+ {+ text: ' %expenses.',+ },+ ];+ }
break;
Note that there can be a few improvements during PR phase, Note that i think that only an admin can undo a payment so the above conditions wont be required for that case, we can simply do the following:
} else {
optimisticNextStep.message = [
{
text: 'Waiting for ',
},
{
text: `you`,
type: 'strong',
},
{
text: ' to ',
},
{
text: 'pay',
},
{
text: ' %expenses.',
},
];
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
N/A this is a UI issue, but we can add additional nextStep tests to mock this action and see if we get correct message
What alternative solutions did you explore? (Optional)
⚠️@twilight2294 Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).
changed the title [-][$250] Delete expene missing after cancel payment[/-][+][Due for payment 2025-02-28] [$250] Delete expene missing after cancel payment[/+]on Feb 21, 2025
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.3-4 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
@dukenv0307@sonialiap@dukenv0307 The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again. Yes
Regression Test Proposal Template
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Activity
melvin-bot commentedon Jan 15, 2025
Triggered auto assignment to @sonialiap (
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.nkdengineer commentedon Jan 15, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
Delete expenes missing after cancel payment
What is the root cause of that problem?
After cancel payment, we are updating
statusNum = CONST.REPORT.STATUS_NUM.CLOSEDwhenapprovalMode === CONST.POLICY.APPROVAL_MODE.OPTIONALhereApp/src/libs/actions/IOU.ts
Lines 7910 to 7912 in 332c9b0
It leads to
isProcessingReport(moneyRequestReport)will be falseApp/src/libs/ReportUtils.ts
Lines 1992 to 1994 in 332c9b0
And in function
canAddOrDeleteTransactionswe return false hereApp/src/libs/ReportUtils.ts
Lines 1996 to 1998 in 332c9b0
What changes do you think we should make in order to solve the problem?
We should update
statusNumtoCONST.REPORT.STATUS_NUM.SUBMITTEDlike BE is returningWhat specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
What alternative solutions did you explore? (Optional)
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
github-actions commentedon Jan 15, 2025
dukenv0307 commentedon Jan 16, 2025
@sonialiap I have the prior context on this issue so I can help take it as C+. Thanks
twilight2294 commentedon Jan 16, 2025
🚨 Edited by proposal-police: This proposal was edited at 2025-01-16 06:50:00 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
There are 2 bugs in this flow:
What is the root cause of that problem?
When we cancel the payment, we set the
statusNumtoCONST.REPORT.STATUS_NUM.CLOSEDwhen the policy approval mode is optional, this causes the bug in offline case where thedeleteandholdbutton are hidden. when we get api response from theBE,statusNumis correctly set toCONST.REPORT.STATUS_NUM.SUBMITTED.App/src/libs/actions/IOU.ts
Line 7912 in 332c9b0
Now, when we
cancel payment, the next steps for a policy with no approval flow enabled is to pay for the expense again. but now we see that no action is required (Which changes again when we get the response from the BE api).What changes do you think we should make in order to solve the problem?
statusNumtoCONST.REPORT.STATUS_NUM.SUBMITTEDhere:Waiting for (name) to approve expense(s).regardless of if the policy has approval flow enabled or not, only doing the change in 1. will cause this regression.So we need to fix this one too, to do that we need to update the following case:
App/src/libs/NextStepUtils.ts
Lines 199 to 200 in 5133090
here, we will put a if condition for the
message:App/src/libs/NextStepUtils.ts
Line 205 in 5133090
To display only when
autoReportingFrequency !== CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANTand for other cases we can directly show the waiting for payment message optimistically, we need to make changes as follows:Details
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
N/A this is a UI issue, but we can add additional nextStep tests to mock this action and see if we get correct message
What alternative solutions did you explore? (Optional)
N/A
github-actions commentedon Jan 16, 2025
[-]Delete expene missing after cancel payment[/-][+][$250] Delete expene missing after cancel payment[/+]melvin-bot commentedon Jan 21, 2025
Job added to Upwork: https://www.upwork.com/jobs/~021881632041880939700
64 remaining items
[-][$250] Delete expene missing after cancel payment[/-][+][Due for payment 2025-02-28] [$250] Delete expene missing after cancel payment[/+]melvin-bot commentedon Feb 21, 2025
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Feb 21, 2025
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.3-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 2025-02-28. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Feb 21, 2025
@dukenv0307 @sonialiap @dukenv0307 The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
dukenv0307 commentedon Feb 24, 2025
BugZero Checklist:
Bug classification
Source of bug:
Where bug was reported:
Who reported the bug:
[Contributor] 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: https://github.com/Expensify/App/pull/48700/files#r1967003299
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again. Yes
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue: https://github.com/Expensify/Expensify/issues/475252
Regression Test Proposal
Test:
Do we agree 👍 or 👎
twilight2294 commentedon Feb 28, 2025
Can someone please pay me for this issue
sonialiap commentedon Feb 28, 2025
Payment summary:
JmillsExpensify commentedon Mar 12, 2025
$250 approved for @dukenv0307