[$250] Report - Expense moved offline to WS with workflows disabled, still shows "Submit" option
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: 9.2.73-1 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/TR-2305/folder/13176670/41237098/1060192756 Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Regression TC Execution Device used: Motorola MotoG60 / Android 12 / Chrome ( mWeb / Hybrid app) - Windows 11 / Chrome App Component: Money Requests
Action Performed:
Prerequisite: Account has at least two workspaces. Prerequisite 2: Workspace 1 has delayed submissions and approvals enabled and workspace 2 has workflows disabled.
- Open the Expensify app.
- Navigate to workspace 1 chat.
- Create a manual expense.
- Open the report of the just created expense.
- Turn off internet connection.
- Tap on "More" > "Change Workspace"
- Select workspace 2 to move the expense to.
- Navigate to the workspace where expense was moved.
- Note that "Submit" option is available on expense preview and also inside report despite "Workflows" being disabled.
- While inside report, tap on "Submit"
- Turn on internet connection.
- Note that "Unexpected error" message appears on the "Submitted" system message.
- Dismiss the error and return to chat.
- Note that a RBR without error message is visible on report preview.
Expected Result:
When an expense is moved from a workspace with delayed submissions and approvals enabled to a workspace with "Workflows" disabled, "Submit" option shouldn´t be available and report should be automatically displayed with "Done" status.
Actual Result:
"Submit" option is still available when moving an expense to a workspace with "Workflows" disabled while offline. Also, tapping on "Submit" while inside of the report, triggers an unexpected error when recovering internet connection, and expense preview shows a RBR without any error message.
Workaround:
Unknown
Platforms:
- [x] Android: App
- [ ] Android: mWeb Chrome
- [ ] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [x] Windows: Chrome
- [ ] MacOS: Chrome / Safari
- [ ] MacOS: Desktop
Screenshots/Videos
https://github.com/user-attachments/assets/a08bd1ad-d649-4137-bb19-99f1694ce4b5
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022003923878847635220
- Upwork Job ID: 2003923878847635220
- Last Price Increase: 2025-12-24
Issue Owner
Current Issue Owner: @dukenv0307
Triggered auto assignment to @mallenexpensify (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.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Report - Expense moved offline to WS with workflows disabled, still shows "Submit" option
What is the root cause of that problem?
In buildOptimisticChangePolicyData we are setting the new expense report's stateNum and statusNum to approved and closed when we move a submitted expense to a policy with disabled workflow. But we are not doing the same when the report we are moving is also open. And since stateNum and statusNum will be a default of open status we return true from isSubmitAction and we will show submit button
https://github.com/Expensify/App/blob/7605a2cf48179b48ee006547672c99594314b21e/src/libs/actions/Report.ts#L5717-L5728
What changes do you think we should make in order to solve the problem?
We should set the report's stateNum to approved and statusNum to closed when the report is also open since the default stateNum and statNum of open expense report created in a workflow disabled workspace is approved and closed.
if ((isProcessingReport(report) || isOpenReport(report)) && isInstantSubmitEnabledLocal && isSubmitAndCloseLocal && arePaymentsDisabled) {
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.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Report - Expense moved offline to WS with workflows disabled, still shows "Submit" option
What is the root cause of that problem?
When moving an expense to a workspace with workflows disabled, the current logic checks if isInstantSubmitEnabled is true before auto-closing the report. However, workspaces with workflows disabled have autoReporting set to false, which makes isInstantSubmitEnabled return false. This causes the report to remain open instead of being automatically closed, incorrectly showing the "Submit" button even though workflows are disabled on that workspace.
https://github.com/Expensify/App/blob/e288b20cdc483c09d30c77cf27124c06da28cc31/src/libs/actions/Report.ts#L5716-L5717
What changes do you think we should make in order to solve the problem?
In the buildOptimisticChangePolicyData function, we should add a direct check for when workflows are disabled areWorkflowsEnabled = false. When this condition is met and the report is in an open or submitted state, we should automatically close the report and set its status to "Done", regardless of the autoReporting setting. This will prevent the Submit button from appearing and ensure the expense correctly displays with a closed status.
The condition should check if workflows are disabled AND approval mode is "Submit & Close" AND the report is open or processing, then close the report immediately.
const arePaymentsDisabled = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO;
const shouldAutoCloseReport =
(areWorkflowsDisabled && isSubmitAndCloseLocal && (isOpenExpenseReport(report) || isProcessingReport(report))) ||
(isProcessingReport(report) && isInstantSubmitEnabledLocal && isSubmitAndCloseLocal && arePaymentsDisabled);
if (shouldAutoCloseReport) {
here
https://github.com/Expensify/App/blob/e288b20cdc483c09d30c77cf27124c06da28cc31/src/libs/actions/Report.ts#L5716-L5717
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.
@mallenexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
@mallenexpensify 6 days overdue. This is scarier than being forced to listen to Vogon poetry!
Will get to soon, lotta repro steps
@mallenexpensify this issue was created 2 weeks ago. Are we close to a solution? Let's make sure we're treating this as a top priority. Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
@mallenexpensify Huh... This is 4 days overdue. Who can take care of this?
Gonna try to get to in AM
Job added to Upwork: https://www.upwork.com/jobs/~022003923878847635220
Triggered auto assignment to Contributor-plus team member for initial proposal review - @dukenv0307 (External)
Took me a bit to reproduce but... i did it!
Marked external, since it's offline-related, unsure if there's anything specific we need/want to do.
Proposal
Please re-state the problem that we are trying to solve in this issue.
"Submit" option is still available when moving an expense to a workspace with "Workflows" disabled while offline. Also, tapping on "Submit" while inside of the report, triggers an unexpected error when recovering internet connection, and expense preview shows a RBR without any error message.
What is the root cause of that problem?
We only update the expense report to Done when moving to a new workspace if the report is processing report
https://github.com/Expensify/App/blob/7605a2cf48179b48ee006547672c99594314b21e/src/libs/actions/Report.ts#L5717-L5728
What changes do you think we should make in order to solve the problem?
I checked the backend behavior in many scenarios, and here is the result
-
If approval is disabled, the report will be
Doneif the stateNum <= 1 (draft/outstanding report) even if the payment/submission is enabled -
If approval is enabled, the status is the same as this logic here
So we should update this condition to only check the isSubmitAndCloseLocal and also apply the logic for draft report
if (i(sProcessingReport(report) || isOpenExpenseReport(report)) && isSubmitAndCloseLocal) {
https://github.com/Expensify/App/blob/7605a2cf48179b48ee006547672c99594314b21e/src/libs/actions/Report.ts#L5717-L5728
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.
If approval is disabled, the report will be Done if the stateNum <= 1 (draft/outstanding report) even if the payment/submission is enabled
@nkdengineer, what if the expense status is Approved or Paid? Does the status change?
@dukenv0307 No the approved/paid state doesn't change
If approval is disabled, the report will be Done if the stateNum <= 1 (draft/outstanding report) even if the payment/submission is enabled
@nkdengineer, what if the expense status is Approved or Paid? Does the status change?
@dukenv0307 ChangeReportPolicy API request shouldn't return APPROVED, and CLOSED state and status name when moving open report to a workspace with only approvers disabled. If you create expense in a workspace with only approvals disabled the state and status num of the report is OPEN. Therefore, ChangeReportPolicy should do the same as RequestMoney when the moved report is OPEN.
ChangeReportPolicy API request response when moving open expense to a workspace with only disabled approvals
Response to RequestMoney API Request on approvals disabled workflow
When we create expense in workspace chat,stateNum will be APPROVED and statusNum will be CLOSED only when isInstantSubmitEnabled is true, arePaymentsDisabled is true and isSubmitAndCloseLocal is true. Therefore we should keep those checks here
https://github.com/Expensify/App/blob/7605a2cf48179b48ee006547672c99594314b21e/src/libs/actions/Report.ts#L5717-L5728
Response to RequestMoney API Request when workflow is disabled (instant submit is enabled, approvals are disabled and payments are disabled)
Hey @mallenexpensify @jponikarchuk, I want to confirm the expected behavior here
- Open the WS chat with disabled approvals
- Create an expense, and observe that the status is Draft
- Open the WS chat with enabled approvals
- Create an expense and observe that the status is Draft
- Open the detailed expense -> click
More-> clickChange workspace - Select the WS at step 1
- Observe that the status now is Done
My question is: Should the status at step 7 be Done or Draft?
https://github.com/user-attachments/assets/8a58367b-f227-4283-aeb0-8d9b9a4ee655
@dukenv0307 On Step 7, report status should be “Done” as the user shouldn't have an option to “Submit” or “Approve” expense
https://github.com/user-attachments/assets/a41db1a4-c42c-4753-a622-ac3860be285f
Thank you @jponikarchuk, let's go with @nkdengineer's proposal. The status should be Done even when the payment is enabled
🎀👀🎀 C+ reviewed
Triggered auto assignment to @carlosmiceli, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
Hi @mallenexpensify @carlosmiceli can you please take a look at this comment for confirmation https://github.com/Expensify/App/issues/77007#issuecomment-3695291903?
cc: @Expensify/design
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
@carlosmiceli can you please take a look a this comment? I don't think we should close an open (draft) report when we move it a workspace with a disabled approvals. I think we should keep the report open as user can submit the open report in the approvals disabled workspace.
If a user creates an expense in approvals disabled workspace the first state of the report is drat, then it will become approved when the user submits it. But in this case, we are trying to close open report when move it to approvals disabled workspace.
cc: Expensify/design
Mmmm, this is more of a product decision, I'll add the label so they can chime in.
@mallenexpensify weird, I was sure there was a label to assign someone from Product, am I mistaken?
Before tagging the product team, below is what I see in the test case. It doesn't specifically say Done, am I missing something?
@jponikarchuk could you help us understand this comment? I think that's what @mallenexpensify is asking above ☝️