App icon indicating copy to clipboard operation
App copied to clipboard

[$250] IOU - GBR is missing from the partially approved expense

Open lanitochka17 opened this issue 1 year ago β€’ 31 comments

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.0.63-1 Reproducible in staging?: Y Reproducible in production?: Y If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/5229984&group_by=cases:section_id&group_id=309128&group_order=asc Issue reported by: Applause - Internal Team

Action Performed:

  • All new Gmail accounts are used
  • Workspace has an admin, member, and approver
  • "Add approvals" is enabled and the approver account is set as the approver
  1. Member: Navigate to https://staging.new.expensify.com/
  2. Member: Log in
  3. Member: Navigate to the workspace chat
  4. Member: Create two manual expenses with any amounts (amounts should be different)
  5. Member: Open one of the expenses
  6. Member: Put the expense on hold
  7. Approver: Log in
  8. Approver: Navigate to the workspace chat
  9. Approver: Click on "Approve"
  10. Approver: Approve just the pending amount

Expected Result:

Newly created report for the held expense is GBR’ed in the LHN (green dot)

Actual Result:

GBR is missing from the partially approved expense

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
  • [x] iOS: mWeb Safari
  • [x] MacOS: Chrome / Safari
  • [ ] MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/user-attachments/assets/3f474518-b1f3-454a-95d9-31f5ffe66435

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021861120032414784544
  • Upwork Job ID: 1861120032414784544
  • Last Price Increase: 2024-11-25
  • Automatic offers:
    • DylanDylann | Reviewer | 105123872
    • nkdengineer | Contributor | 105123876
Issue OwnerCurrent Issue Owner: @DylanDylann

lanitochka17 avatar Nov 15 '24 19:11 lanitochka17

Triggered auto assignment to @OfstadC (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.

melvin-bot[bot] avatar Nov 15 '24 19:11 melvin-bot[bot]

Not overdue Mel - it was the weekend. Will review this tomorrow AM

OfstadC avatar Nov 18 '24 22:11 OfstadC

@lanitochka17

GBR should be visible

What specifically is missing here

OfstadC avatar Nov 19 '24 21:11 OfstadC

It seems normal to me πŸ€”

OfstadC avatar Nov 19 '24 21:11 OfstadC

https://expensify.slack.com/archives/C9YU7BX5M/p1732211583025239

OfstadC avatar Nov 21 '24 17:11 OfstadC

Still reproducible. Actions performed are same, updated the expected result

https://github.com/user-attachments/assets/0a320849-d16d-4448-afc6-af7f90700335

kavimuru avatar Nov 22 '24 12:11 kavimuru

OMG - It was not clear what GBR was to me - April was a saint and helped me!

OfstadC avatar Nov 22 '24 17:11 OfstadC

I actually think this is a dupe of this

OfstadC avatar Nov 22 '24 19:11 OfstadC

Re-reviewing the other issue it seems they are closely related but differ a bit. Adding to #expense

OfstadC avatar Nov 25 '24 18:11 OfstadC

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

melvin-bot[bot] avatar Nov 25 '24 18:11 melvin-bot[bot]

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

melvin-bot[bot] avatar Nov 25 '24 18:11 melvin-bot[bot]

Edited by proposal-police: This proposal was edited at 2024-11-26 05:05:16 UTC.

Proposal

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

GBR is missing from the partially approved expense

What is the root cause of that problem?

If we approve partially, a new expense report will be created with statusNum and stateNum are getting from here

https://github.com/Expensify/App/blob/38568ed1349fc31e53dff2bc64d572d64d4c435f/src/libs/actions/IOU.ts#L6324

If isInstantSubmitEnabled and payment is not disabled, the new expense report is marked as submitted.

https://github.com/Expensify/App/blob/38568ed1349fc31e53dff2bc64d572d64d4c435f/src/libs/ReportUtils.ts#L4646-L4649

But in this case hasOutstandingChildRequest is updated to false here before we get the onyx data of the partially case

https://github.com/Expensify/App/blob/38568ed1349fc31e53dff2bc64d572d64d4c435f/src/libs/actions/IOU.ts#L6990

So no GBR is displayed in LHN

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

If we approve in full, we can update hasOutstandingChildRequest like this

https://github.com/Expensify/App/blob/38568ed1349fc31e53dff2bc64d572d64d4c435f/src/libs/actions/IOU.ts#L6990

In this case, it is not full, we need to update hasOutstandingChildRequest of the chat report to true if the new expense report is marked as submitted https://github.com/Expensify/App/blob/38568ed1349fc31e53dff2bc64d572d64d4c435f/src/libs/actions/IOU.ts#L7077

  1. We need to move this optimistic data to this case
if (full && hasHeldExpenses) {
      optimisticData.push({
          onyxMethod: Onyx.METHOD.MERGE,
          key: `${ONYXKEYS.COLLECTION.REPORT}${expenseReport?.chatReportID}`,
          value: {
              hasOutstandingChildRequest: hasIOUToApproveOrPay(chatReport, expenseReport?.reportID ?? '-1'),
          },
      });

https://github.com/Expensify/App/blob/38568ed1349fc31e53dff2bc64d572d64d4c435f/src/libs/actions/IOU.ts#L6986

  1. In getReportFromHoldRequestsOnyxData function, update hasOutstandingChildRequest of chat report to true if the new expense report is marked as submitted
hasOutstandingChildRequest: optimisticExpenseReport.stateNum === CONST.REPORT.STATE_NUM.SUBMITTED && optimisticExpenseReport.statusNum === CONST.REPORT.STATE_NUM.SUBMITTED,

https://github.com/Expensify/App/blob/38568ed1349fc31e53dff2bc64d572d64d4c435f/src/libs/actions/IOU.ts#L6405

  1. Require backend change: Backend also needs to update hasOutstandingChildRequest to true in this case of ApproveMoneyRequest API

What alternative solutions did you explore? (Optional)

nkdengineer avatar Nov 25 '24 19:11 nkdengineer

@nkdengineer Do we need to require BE change to fix this issue?

DylanDylann avatar Nov 26 '24 04:11 DylanDylann

It seems the BE return wrong hasOutstandingChildRequest in this case

DylanDylann avatar Nov 26 '24 04:11 DylanDylann

@DylanDylann you're right, updated proposal.

nkdengineer avatar Nov 26 '24 05:11 nkdengineer

There are some new updates that block partially approve flow. Just ask to clarify https://github.com/Expensify/App/issues/50479#issuecomment-2499693630

DylanDylann avatar Nov 26 '24 05:11 DylanDylann

@nkdengineer's proposal looks good to me

πŸŽ€ πŸ‘€ πŸŽ€ C+ Reviewed

DylanDylann avatar Nov 28 '24 03:11 DylanDylann

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

melvin-bot[bot] avatar Nov 28 '24 03:11 melvin-bot[bot]

@NikkiWines Please help to take a look when you have a chance.

nkdengineer avatar Nov 29 '24 03:11 nkdengineer

@OfstadC @NikkiWines @DylanDylann 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!

melvin-bot[bot] avatar Nov 29 '24 09:11 melvin-bot[bot]

Yep, agreed the proposal looks good πŸ‘

NikkiWines avatar Nov 29 '24 13:11 NikkiWines

πŸ“£ @DylanDylann πŸŽ‰ An offer has been automatically sent to your Upwork account for the Reviewer role πŸŽ‰ Thanks for contributing to the Expensify app!

Offer link Upwork job

melvin-bot[bot] avatar Nov 29 '24 13:11 melvin-bot[bot]

πŸ“£ @nkdengineer πŸŽ‰ 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] avatar Nov 29 '24 13:11 melvin-bot[bot]

In this case, it is not full, we need to update hasOutstandingChildRequest of the chat report to true if the new expense report is marked as submitted

@NikkiWines We have a draft PR here. Base on this description, can you please handle the backend change in ApproveMoneyRequest?

nkdengineer avatar Dec 02 '24 04:12 nkdengineer

Yep, I'll start working on that asap

NikkiWines avatar Dec 02 '24 12:12 NikkiWines

@OfstadC, @NikkiWines, @DylanDylann, @nkdengineer Whoops! This issue is 2 days overdue. Let's get this updated quick!

melvin-bot[bot] avatar Dec 03 '24 09:12 melvin-bot[bot]

Sorry for the delay here, I actually want to just run this by @marcochavezf to confirm intended functionality here.

@marcochavezf I see you in the blame here where we set hasOutstandingChildRequest to false to clear the GBR parent report - how do you feel about updating that to do so only if isFullApproval is true so that in the case of a partial approval the parent report has the GBR added?

NikkiWines avatar Dec 04 '24 20:12 NikkiWines

Not overdue

DylanDylann avatar Dec 05 '24 03:12 DylanDylann

how do you feel about updating that to do so only if isFullApproval is true so that in the case of a partial approval the parent report has the GBR added?

Oh sound good, the hasOutstandingChildRequest set to false was implemented before we had partial approvements, so yeah it makes sense to check if is full approval is true for this case

marcochavezf avatar Dec 05 '24 13:12 marcochavezf

Backend PR is up

NikkiWines avatar Dec 06 '24 11:12 NikkiWines