Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DISTANCE] MEDIUM: [$500] Only allow admins to manually edit distance request amount and currency #30654

Closed
6 tasks done
m-natarajan opened this issue Oct 31, 2023 · 57 comments
Closed
6 tasks done
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Distance Wave5-free-submitters Internal Requires API changes or must be handled by Expensify staff Reviewing Has a PR in review Weekly KSv2

Comments

@m-natarajan
Copy link

m-natarajan commented Oct 31, 2023

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: 1.3.93-1
Reproducible in staging?: y
Reproducible in production?: y
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: @esh-g
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1698001650923669

Action Performed:

  1. Make a new distance request.
  2. Go to the request.
  3. After it has loaded, go offline.
  4. Change the currency in the amount.
  5. Go back online.

Expected Result:

The currency should be changed

Actual Result:

The currency is not changed.

Workaround:

unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2023-10-23.at.12.21.12.AM.mov
Recording.188.mp4
MacOS: Desktop

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01f9c85c43ba1d6c35
  • Upwork Job ID: 1719835802236735488
  • Last Price Increase: 2023-11-01
  • Automatic offers:
    • alitoshmatov | Reviewer | 27772651
    • DylanDylann | Contributor | 27772653
    • esh-g | Reporter | 27772658
Issue OwnerCurrent Issue Owner: @Gonals
@DylanDylann
Copy link
Contributor

DylanDylann commented Oct 31, 2023

Proposal

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

  • Unable to change currency when offline in distance request

What is the root cause of that problem?

  • Currently, when calling UpdateDistanceRequest with currency data, BE does not update the currency, it still returns the original currency.
  • When the user is in offline mode, and updates currency from "A" to "B", optimisticData is update to B. Then turn on the network, API will be called and updated to currency to A. That leads to the current behavior.

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

Firstly, please check this discussion: https://expensify.slack.com/archives/C01GTK53T8Q/p1698949355446899?thread_ts=1697575566.549679&cid=C01GTK53T8Q

We should not allow editing the amount or currency when creating distance request or editing distance request.
We only allow the admin of the workspace to edit the amount or currency when editing distance request.

  1. We need to disable the amount field when creating distance request
    In here
    interactive={!props.isReadOnly}

    we should update like this
interactive={!props.isReadOnly && !props.isDistanceRequest}
  1. We only allow admin of workspace to edit the amount field when editing distance request
    In here
    interactive={canEdit && !isSettled}
    shouldShowRightIcon={canEdit && !isSettled}

    Update like this
interactive={canEdit && !isSettled && (isDistanceRequest ? isAdmin : true)}
shouldShowRightIcon={canEdit && !isSettled && (isDistanceRequest ? isAdmin : true)}
  1. Prevent user (exclude admin) from going to edit amount page when editing distance request by deeplink
    In here
    if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.AMOUNT) {

    update like this
    if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.AMOUNT && (TransactionUtils.isDistanceRequest(transaction) ? isAdmin : true)) {

OR, we can dismiss modal if the user goes to the edit page by deep link

  1. Prevent the user from going to amount page when creating distance request by deeplink
    In here
    <FullPageNotFoundView shouldShow={!IOUUtils.isValidMoneyRequestType(iouType)}>

    update like this
                <FullPageNotFoundView shouldShow={!IOUUtils.isValidMoneyRequestType(iouType) || isDistanceRequestTab}>

OR, we can dismiss modal if the user goes to the edit page by deep link

We also need update from BE follow this requirement:
We should not allow editing the amount or currency when creating distance request or editing distance request.
We only allow the admin of the workspace to edit the amount or currency when editing distance request.

@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 31, 2023
Copy link

melvin-bot bot commented Oct 31, 2023

Triggered auto assignment to @twisterdotcom (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

Copy link

melvin-bot bot commented Oct 31, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@twisterdotcom twisterdotcom added the External Added to denote the issue can be worked on by a contributor label Nov 1, 2023
@melvin-bot melvin-bot bot changed the title Unable to change currency when offline in distance request [$500] Unable to change currency when offline in distance request Nov 1, 2023
Copy link

melvin-bot bot commented Nov 1, 2023

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Nov 1, 2023
Copy link

melvin-bot bot commented Nov 1, 2023

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

@samilabud
Copy link
Contributor

Proposal

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

Unable to change currency when offline in distance request

What is the root cause of that problem?

When we update the currency using 'distance request' we use a method called IOU.updateDistanceRequest, this method doesn't update the currency (this behavior occurs online - if you update the page you can see the currency is the first one you selected- and offline).

IOU.updateDistanceRequest(transaction.transactionID, report.reportID, transactionChanges);

These are the API request and response of IOU.updateDistanceRequest function:

API Request payload API Response DOP

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

I think the simplest change is to call the function (used in the manual request) IOU.editMoneyRequest method when using 'distance request' as shown below :

function editMoneyRequest(transactionChanges) {

function editMoneyRequest(transactionChanges) {
        if (TransactionUtils.isDistanceRequest(transaction)) {
            IOU.updateDistanceRequest(transaction.transactionID, report.reportID, transactionChanges);
            IOU.editMoneyRequest(transaction.transactionID, report.reportID, transactionChanges);
        } else {
            IOU.editMoneyRequest(transaction.transactionID, report.reportID, transactionChanges);
        }
        Navigation.dismissModal(report.reportID);
    }

This is the result:

Fixed.Unable.to.change.currency.when.offline.in.distance.request.test.mp4

@bernhardoj
Copy link
Contributor

Proposal

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

Changing the distance request currency will revert back to the previous currency.

What is the root cause of that problem?

When we change the currency of a distance request, we will optimistically update it, but the BE actually doesn't allow it, so the value/currency will be reverted.

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

Currently, BE doesn't allow us to change the distance request currency, but allows us to change the distance request amount. I'm pretty sure we want to disallow both because on the distance request confirm page, the amount button is completely disabled. This is because the amount is calculated from the distance.

So, my suggestion is to also disable the amount button on the report/chat page if it's a distance request.

<MenuItemWithTopDescription
title={formattedTransactionAmount ? formattedTransactionAmount.toString() : ''}
shouldShowTitleIcon={isSettled}
titleIcon={Expensicons.Checkmark}
description={amountDescription}
titleStyle={styles.newKansasLarge}
interactive={canEdit && !isSettled}
shouldShowRightIcon={canEdit && !isSettled}
onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.AMOUNT))}
brickRoadIndicator={hasErrors && transactionAmount === 0 ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''}
error={hasErrors && transactionAmount === 0 ? translate('common.error.enterAmount') : ''}
/>

interactive={canEdit && !isSettled && !isDistanceRequest}
shouldShowRightIcon={canEdit && !isSettled && !isDistanceRequest}

@melvin-bot melvin-bot bot added the Overdue label Nov 6, 2023
Copy link

melvin-bot bot commented Nov 7, 2023

@twisterdotcom, @alitoshmatov Eep! 4 days overdue now. Issues have feelings too...

@twisterdotcom
Copy link
Contributor

Some internal discussions actually ongoing now about whether to even allow changing the currency of a distance request. Please HOLD. https://expensify.slack.com/archives/C03SSAQ7P/p1698248408690509

cc @neil-marcellini

@melvin-bot melvin-bot bot removed the Overdue label Nov 7, 2023
@twisterdotcom twisterdotcom changed the title [$500] Unable to change currency when offline in distance request [HOLD] [$500] Unable to change currency when offline in distance request Nov 7, 2023
@melvin-bot melvin-bot bot added the Overdue label Nov 9, 2023
@twisterdotcom
Copy link
Contributor

Okay, @neil-marcellini am I right now that we don't want to allow for changing the currency at all now? Once it's created, the currency is set by the workspace it's created on.

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Nov 9, 2023
@alitoshmatov
Copy link
Contributor

Reviewing

@melvin-bot melvin-bot bot removed the Overdue label Nov 13, 2023
@alitoshmatov
Copy link
Contributor

@DylanDylann proposal looks good and tests well, also it covers all cases where page is accessed through deeplink.

C+ reviewed 🎀 👀 🎀

Copy link

melvin-bot bot commented Nov 13, 2023

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

@alitoshmatov
Copy link
Contributor

alitoshmatov commented Nov 13, 2023

@samilabud Your proposal misses a point which we are not allowing changing currency

@bernhardoj your proposal is similar to @DylanDylann 's proposal, also it does not cover deeplink access

@twisterdotcom
Copy link
Contributor

@neil-marcellini would love your technical input here. We won't allow currency changes at all now, we will just eventually allow moving different currency distance expenses between different currency workspaces. If so, I think we should close this, as offline is working fine and we would need to change online.

@neil-marcellini neil-marcellini added the Reviewing Has a PR in review label Dec 9, 2023
@neil-marcellini
Copy link
Contributor

The Auth PR has changes requested, because we switched to a new command while I was working on this, so I need to move the changes over there before putting this up for review again.

@neil-marcellini neil-marcellini removed the Reviewing Has a PR in review label Dec 13, 2023
@melvin-bot melvin-bot bot added the Overdue label Dec 18, 2023
Copy link

melvin-bot bot commented Dec 19, 2023

@twisterdotcom, @neil-marcellini, @alitoshmatov, @DylanDylann Eep! 4 days overdue now. Issues have feelings too...

@neil-marcellini
Copy link
Contributor

I'll try to squeeze in some updates to my backend PR tomorrow.

@melvin-bot melvin-bot bot removed the Overdue label Dec 19, 2023
@neil-marcellini
Copy link
Contributor

I got the backend PR up for review again

@neil-marcellini neil-marcellini added the Reviewing Has a PR in review label Dec 20, 2023
@neil-marcellini
Copy link
Contributor

The backend PR was finally merged and should be deployed today. @DylanDylann you can probably finish off the frontend PR soon.

@neil-marcellini
Copy link
Contributor

The Auth PR was deployed

@DylanDylann
Copy link
Contributor

Thanks @neil-marcellini

@neil-marcellini
Copy link
Contributor

❗ 🔥 Heads up, I'm going to be OOO working 0% from 1/1-1/12/24. I'll be back on 1/15/24. I'm planning to work 50% tomorrow 12/29. Please feel free to un-assign, re-assign, whatever. When I return I'll pick back up whatever I can and do my best to GSD in order of priority. I will also post all of my assigned issues in #engineering-chat in Slack to try to recruit volunteers.

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Jan 2, 2024
@alitoshmatov
Copy link
Contributor

@twisterdotcom PR is ready for a review by internal engineer, can you reassign another internal for engineer since @neil-marcellini is OOO till 15th January

@twisterdotcom
Copy link
Contributor

@alitoshmatov could you link the PR? I'll find an engineer.

@twisterdotcom twisterdotcom added Internal Requires API changes or must be handled by Expensify staff and removed Internal Requires API changes or must be handled by Expensify staff labels Jan 4, 2024
Copy link

melvin-bot bot commented Jan 4, 2024

Current assignee @alitoshmatov is eligible for the Internal assigner, not assigning anyone new.

@twisterdotcom
Copy link
Contributor

Eugh, it will do the same for Neil. Let me see who's on the Wave 5 team.

@alitoshmatov
Copy link
Contributor

The PR is here #31778

@alitoshmatov
Copy link
Contributor

The PR was deployed to product in 9th of january. I think this one is ready for payment

cc: @twisterdotcom

@twisterdotcom
Copy link
Contributor

Weird we didn't get the automation. Okay, gonna send offers to you all.

@twisterdotcom
Copy link
Contributor

Oh wait, the offers are there. Weird. Sorry for the duplicate offers - I withdrew the ones I just made and paid the ones we automated last year. Okay:

Payment Summary:

@alitoshmatov paid $500 here (C+)
@DylanDylann paid $500 here (Contributor)
@esh-g paid $50 here (Reporter)

@twisterdotcom
Copy link
Contributor

Gonna close, no need for regression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Distance Wave5-free-submitters Internal Requires API changes or must be handled by Expensify staff Reviewing Has a PR in review Weekly KSv2
Projects
No open projects
Development

No branches or pull requests

10 participants