Skip to content

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

Closed

Description

@m-natarajan

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

Activity

  1. DylanDylann commented on Oct 31, 2023

    @DylanDylann
    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?

    • 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.

  2. added
    Daily
    Bug
    on Oct 31, 2023
  3. melvin-bot commented on Oct 31, 2023

    @melvin-bot

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

  4. melvin-bot commented on Oct 31, 2023

    @melvin-bot

    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
  5. added
    External
    on Nov 1, 2023
  6. changed the title [-]Unable to change currency when offline in distance request[/-] [+][$500] Unable to change currency when offline in distance request[/+] on Nov 1, 2023
  7. melvin-bot commented on Nov 1, 2023

    @melvin-bot
  8. added
    Help Wanted
    on Nov 1, 2023
  9. melvin-bot commented on Nov 1, 2023

    @melvin-bot

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

  10. samilabud commented on Nov 2, 2023

    @samilabud
    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
  11. bernhardoj commented on Nov 2, 2023

    @bernhardoj
    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}
    
  12. 77 remaining items

  13. added
    Internal
    and removed
    Internal
    on Jan 4, 2024
  14. melvin-bot commented on Jan 4, 2024

    @melvin-bot

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

  15. twisterdotcom commented on Jan 4, 2024

    @twisterdotcom
    Contributor

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

  16. alitoshmatov commented on Jan 4, 2024

    @alitoshmatov
    Contributor

    The PR is here #31778

  17. moved this from Release 3: Card Experience to Release 2: Migration for All in [#whatsnext] Wave 05 - Deprecate Freeon Jan 5, 2024
  18. alitoshmatov commented on Jan 18, 2024

    @alitoshmatov
    Contributor

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

    cc: @twisterdotcom

  19. twisterdotcom commented on Jan 18, 2024

    @twisterdotcom
    Contributor

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

  20. twisterdotcom commented on Jan 18, 2024

    @twisterdotcom
    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)

  21. twisterdotcom commented on Jan 18, 2024

    @twisterdotcom
    Contributor

    Gonna close, no need for regression.

  22. moved this from Release 3: Migration for All to Done in [#whatsnext] Wave 05 - Deprecate Freeon Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugDistanceInternalReviewingWeekly

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions