Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.98k stars 2.98k forks source link

[$250] Users can't submit a report that contains no reimbursable expenses #55086

Open trjExpensify opened 2 weeks ago

trjExpensify commented 2 weeks ago

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


Version Number: 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: @danielrvidal Slack conversation (hyperlinked to channel name): #retain

Action Performed:

  1. Go to NewDot, create a workspace.
  2. Go to Settings > Workspaces > [Click the workspace] > Enable Workflows
  3. Go to Workflows > Enable delayed submission and set it to Manually > Enable approvals.
  4. Go to Members > invite a member to the workspace
  5. [Member] Click the green plus icon > Create expense > choose the workspace > confirm
  6. Observe the Submit button on the report preview, in the report header, and on the search page.
  7. [Member] Click Settings > Domains (to transition over to OldDot)
  8. [Member] Go to the Expenses page > click into the expense > uncheck the reimbursable checkmark
  9. [Member] open the NewDot tab > refresh
  10. Observe the Submit button is no longer visible on the report preview, report header or search page.

Expected Result:

Users should be able to see the Submit button on an expense report that contains only non-reimbursable expenses, providing they aren't all pending transactions.

Actual Result:

There's no Submit button on an expense report that contains only non-reimbursable expenses.

Note: I think this line here is culprit. Perhaps it's also in a few other places where you see the submit button.

Workaround:

They can submit via OldDot.

Platforms:

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

Screenshots/Videos

https://github.com/user-attachments/assets/7ed3c5e0-c80a-4e69-9510-a4fd7a524f31

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021877786460553153940
  • Upwork Job ID: 1877786460553153940
  • Last Price Increase: 2025-01-10
  • Automatic offers:
    • shubham1206agra | Contributor | 105671141
    • ishpaul777 | Contributor | 105671147
Issue OwnerCurrent Issue Owner: @s77rt
melvin-bot[bot] commented 2 weeks ago

Current assignee @trjExpensify is eligible for the Bug assigner, not assigning anyone new.

melvin-bot[bot] commented 2 weeks ago

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

melvin-bot[bot] commented 2 weeks ago

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

allroundexperts commented 2 weeks ago

@trjExpensify Your clue is accurate.

allroundexperts commented 2 weeks ago

We need to remove the condition here in the money report header as well. There's also a condition in the submission action that we need to remove.

allgandalf commented 2 weeks ago

@trjExpensify Your clue is accurate.

@trjExpensify is gonna take our job away !!!!!

allroundexperts commented 2 weeks ago

Haha ❤️

mohit6789 commented 2 weeks ago

Proposal

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

Users can't submit a report that contains no reimbursable expenses

What is the root cause of that problem?

Button only show in case of reimbursableSpend != 0 as mention by @trjExpensify.

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

We need to make sure button is showing in case of reimbursableSpend is 0. For this we need to remove reimbursableSpend !== 0 condition in this three places.

https://github.com/allroundexperts/Expensify/blob/3b665f7ff38fc7b3b7155e84eb0d09e680742a82/src/components/MoneyReportHeader.tsx#L149

https://github.com/allroundexperts/Expensify/blob/3b665f7ff38fc7b3b7155e84eb0d09e680742a82/src/libs/actions/IOU.ts#L7408

https://github.com/Expensify/App/blob/d7a0088f372936d346319a966724a933036f7dbd/src/components/ReportActionItem/ReportPreview.tsx#L205

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

NA

What alternative solutions did you explore? (Optional)

allroundexperts commented 2 weeks ago

Proposal

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

Users can't submit a report that contains no reimbursable expenses

What is the root cause of that problem?

As stated by @trjExpensify, we have this line that prevents the submit button from appearing if the expense is not reimbursable.

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

We need to remove the conditions that block submission if the expense is not reimbursable. Particularly, we need to remove the condition here, here and here.

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

Adding a regression test for submitting a non reimbursable expense should suffice.

What alternative solutions did you explore? (Optional)

N/A

twilight2294 commented 2 weeks ago

Proposal

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

Users can't submit a report that contains no reimbursable expenses

What is the root cause of that problem?

We only check for reimbursableSpend !== 0:

https://github.com/Expensify/App/blob/d7a0088f372936d346319a966724a933036f7dbd/src/components/ReportActionItem/ReportPreview.tsx#L205

This causes the button to be hidden

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

We need to update the condition such that it will not show only when the reimbursible - non-reimbursible = 0:

    const shouldShowSubmitButton =
        isOpenExpenseReport &&
        (reimbursableSpend - nonReimbursableSpend) !== 0 &&

We need to update other places as well here and here

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

What alternative solutions did you explore? (Optional)

shubham1206agra commented 2 weeks ago

Edited by proposal-police: This proposal was edited at 2025-01-10 19:14:25 UTC.

Proposal

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

Users can't submit a report that contains no reimbursable expenses

What is the root cause of that problem?

As stated by @trjExpensify, we have this line that prevents the submit button from appearing if the expense is not reimbursable. We should have checked for totalSpend instead of reimbursableSpend.

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

We need to update the conditions that block submission if the expense is not reimbursable. Particularly, we need to update the condition here, here and here.

The updated condition should be totalDisplaySpend !== 0 to check for total spend instead of reimbursable spend in case of the submit button.

[!NOTE] We should also check conditions for approvals too for the same problem.

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

Adding a regression test for submitting a non reimbursable expense should suffice.

What alternative solutions did you explore? (Optional)

N/A

allroundexperts commented 2 weeks ago

The updated condition should be totalDisplaySpend !== 0 to check for total spend instead of reimbursable spend in case of the submit button.

Can we have a case @shubham1206agra where a money report is created and it has a 0 spend?

allroundexperts commented 2 weeks ago

Ah, I see. If a scan fails, then the total spend would be 0 unless entered manually. Till its entered, we shouldn't show the submit button. Adding totalDisplaySpend is better. 👍

ishpaul777 commented 2 weeks ago

taking over c+ role https://expensify.slack.com/archives/C02NK2DQWUX/p1736539732521579?thread_ts=1736534208.861619&cid=C02NK2DQWUX

@shubham1206agra's proposal makes sense to me a works as expected.

🎀 👀 🎀

melvin-bot[bot] commented 2 weeks ago

Triggered auto assignment to @lakchote, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

ishpaul777 commented 2 weeks ago

We should also check conditions for approvals too for the same problem.

can you please list test steps for such cases @shubham1206agra

twilight2294 commented 1 week ago

taking over c+ role https://expensify.slack.com/archives/C02NK2DQWUX/p1736539732521579?thread_ts=1736534208.861619&cid=C02NK2DQWUX

@shubham1206agra's proposal makes sense to me a works as expected.

🎀 👀 🎀

@lakchote @ishpaul777 In my proposal i used reimbursableSpend - nonReimbursableSpend because it is more readable and easy to understand the condition when shouldShowSubmitButton should be true :)) , both the proposals are going to yield the same result , so can you re-review the proposal please

shubham1206agra commented 1 week ago

taking over c+ role https://expensify.slack.com/archives/C02NK2DQWUX/p1736539732521579?thread_ts=1736534208.861619&cid=C02NK2DQWUX @shubham1206agra's proposal makes sense to me a works as expected. 🎀 👀 🎀

@lakchote @ishpaul777 In my proposal i used reimbursableSpend - nonReimbursableSpend because it is more readable and easy to understand the condition when shouldShowSubmitButton should be true :)) , both the proposals are going to yield the same result , so can you re-review the proposal please

Haha what?? @twilight2294 I think you used wrong notation here. I think what you meant to do is reimbursableSpend + nonReimbursableSpend instead of current one. Current one will cause problem when both reimbursable and non reimbursable spends are equal.

melvin-bot[bot] commented 1 week ago

Current assignee @lakchote is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

twilight2294 commented 1 week ago

Thanks for responding @shubham1206agra .

I think what you meant to do is reimbursableSpend + nonReimbursableSpend instead of current one.

No it should be reimbursableSpend - nonReimbursableSpend itself, getMoneyRequestSpendBreakdown returns + values for both the variables

Current one will cause problem when both reimbursable and non reimbursable spends are equal.

When both are equal we shouldn't show the submit button at all right ? even with your proposal we won't show the submit button when both will be equal

lakchote commented 1 week ago

@shubham1206agra's proposal LGTM.

@shubham1206agra could you address this comment from @ishpaul777 please?

melvin-bot[bot] commented 1 week ago

📣 @shubham1206agra 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻 Keep in mind: Code of Conduct | Contributing 📖

melvin-bot[bot] commented 1 week ago

📣 @ishpaul777 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻 Keep in mind: Code of Conduct | Contributing 📖

shubham1206agra commented 1 week ago

@shubham1206agra's proposal LGTM.

@shubham1206agra could you address this comment from @ishpaul777 please?

@lakchote This will be addressed in https://github.com/Expensify/App/issues/54996 actually.

twilight2294 commented 1 week ago

@shubham1206agra , @lakchote I guess, @allroundexperts 's proposal to remove the check is correct here.

Saying cause you can test the following:

  1. Go to OD > Create a workspace > enable delayed submission > create 2 expenses > one with +10 value and other with -10 value
  2. Open the report on OD

You will see a submit button for the report:

Image
  1. Open ND for the same account, notice that there is no submit button displayed.
Image

So i guess the correct approach is to remove that check completely, what do you guys think ?

shubham1206agra commented 1 week ago

Let me discuss this with @trjExpensify here https://expensify.slack.com/archives/C02NK2DQWUX/p1736534208861619

Edit - I don't think we should be able to submit expenses if total is zero.

mohit6789 commented 1 week ago

@shubham1206agra could you please add the Slack discussion details here in the comment as I don't have access to Slack?

ishpaul777 commented 1 week ago

@shubham1206agra can you please update the status of PR?

shubham1206agra commented 1 week ago

Will open a PR by EOD

lakchote commented 5 days ago

@shubham1206agra any ETA on the PR?

shubham1206agra commented 4 days ago

@lakchote I am discussing some last questions here https://expensify.slack.com/archives/C02NK2DQWUX/p1737390502910259. Just to make sure no future bugs arises here.

shubham1206agra commented 2 days ago

Update - Draft PR is up. Waiting for first round of review by C+.

melvin-bot[bot] commented 2 days ago

@trjExpensify @lakchote @shubham1206agra @ishpaul777 this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

trjExpensify commented 1 day ago

@shubham1206agra should you convert that into reviewing if we're asking C+ to review? Melvin will leave us alone then ;)