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

[HOLD for payment 2024-04-09] [Simplified Collect][Distance rates] - Distance rates disappear when changing default workspace currency offline #38928

Closed
6 tasks done
izarutskaya opened this issue Mar 25, 2024 · 16 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Internal Requires API changes or must be handled by Expensify staff

Comments

@izarutskaya
Copy link

izarutskaya commented Mar 25, 2024

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: 1.4.56-2
Reproducible in staging?: Y
Reproducible in production?: Y
Logs: https://stackoverflow.com/c/expensify/questions/4856
Issue reported by: Applause-Internal team

Action Performed:

Precondition:

  • User is admin of Collect workspace.
  1. Go to staging.new.expensify.com.
  2. Go to Profile > Workspaces > Collect workspace.
  3. Go to Distance rates.
  4. Add a few distance rates.
  5. Go offline.
  6. Go to workspace profile > Currency > Change to a different currency.
  7. Go to Distance rates.

Expected Result:

All the available distance rates will still be present after changing workspace default currency offline.

Actual Result:

Only one distance rate is present after changing workspace default currency offline. The rest reappears after returning online.

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

Bug6425812_1711365129588.20240325_190626.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~010ef3b0c77b5b3ce7
  • Upwork Job ID: 1772808192831074304
  • Last Price Increase: 2024-03-27
Issue OwnerCurrent Issue Owner: @alitoshmatov
@izarutskaya izarutskaya added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Mar 25, 2024
Copy link

melvin-bot bot commented Mar 25, 2024

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

@izarutskaya
Copy link
Author

We think that this bug might be related to #wave-control.

@abzokhattab
Copy link
Contributor

abzokhattab commented Mar 25, 2024

Proposal

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

Distance rates disappear when changing default workspace currency offline

What is the root cause of that problem?

when changing the currency, we set the optimistic value of the default rate value only, we dont set the rest

App/src/libs/actions/Policy.ts

Lines 1338 to 1367 in 250baa9

const distanceRate = Object.values(distanceUnit?.rates ?? {}).find((rate) => rate.name === CONST.CUSTOM_UNITS.DEFAULT_RATE);
const optimisticData: OnyxUpdate[] = [
{
// We use SET because it's faster than merge and avoids a race condition when setting the currency and navigating the user to the Bank account page in confirmCurrencyChangeAndHideModal
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
...policy,
pendingFields: {
generalSettings: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
// Clear errorFields in case the user didn't dismiss the general settings error
errorFields: {
generalSettings: null,
},
name,
outputCurrency: currency,
...(distanceUnit?.customUnitID && distanceRate?.customUnitRateID
? {
customUnits: {
[distanceUnit?.customUnitID]: {
...distanceUnit,
rates: {
[distanceRate?.customUnitRateID]: {
...distanceRate,
currency,
},

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

we need to update all available rates .. not only the default one:

   const distanceRates = distanceUnit?.rates ?? {};
    Object.keys(distanceRates).forEach((id) => {
        distanceRates[id] = {
            ...distanceRates[id],
            currency,
        };
    });

and change the optimistic value here to:

      ...(distanceUnit?.customUnitID
                    ? {
                          customUnits: {
                              [distanceUnit?.customUnitID]: {
                                  ...distanceUnit,
                                  rates: distanceRates,
                              },
                          },
                      }
                    : {}),

also we need to change the failure value here to the original rates object:

                          customUnits: distanceUnit?.rates,

POC

Screen.Recording.2024-03-25.at.4.31.46.PM.mov

@luacmartins luacmartins self-assigned this Mar 26, 2024
@luacmartins luacmartins changed the title Distance rates - Distance rates disappear when changing default workspace currency offline [Simplified Collect][Distance rates] - Distance rates disappear when changing default workspace currency offline Mar 26, 2024
@kadiealexander kadiealexander added the Internal Requires API changes or must be handled by Expensify staff label Mar 27, 2024
Copy link

melvin-bot bot commented Mar 27, 2024

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

Copy link

melvin-bot bot commented Mar 27, 2024

Triggered auto assignment to Contributor Plus for review of internal employee PR - @alitoshmatov (Internal)

@MrMuzyk
Copy link
Contributor

MrMuzyk commented Mar 27, 2024

I am Michał from Callstack - expert contributor group. I’d like to work on this job.

@Christinadobrzyn
Copy link
Contributor

hi! Could you confirm if this job is related ? I think it might be?

#36680

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Apr 2, 2024
@melvin-bot melvin-bot bot changed the title [Simplified Collect][Distance rates] - Distance rates disappear when changing default workspace currency offline [HOLD for payment 2024-04-09] [Simplified Collect][Distance rates] - Distance rates disappear when changing default workspace currency offline Apr 2, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Apr 2, 2024
Copy link

melvin-bot bot commented Apr 2, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Apr 2, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.58-8 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-04-09. 🎊

For reference, here are some details about the assignees on this issue:

  • @MrMuzyk does not require payment (Contractor)
  • @alitoshmatov requires payment (Needs manual offer from BZ)

Copy link

melvin-bot bot commented Apr 2, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@alitoshmatov] The PR that introduced the bug has been identified. Link to the PR:
  • [@alitoshmatov] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@alitoshmatov] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@alitoshmatov] Determine if we should create a regression test for this bug.
  • [@alitoshmatov] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@kadiealexander] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@luacmartins
Copy link
Contributor

@kadiealexander I think #36680 is its own thing.

@kadiealexander
Copy link
Contributor

kadiealexander commented Apr 9, 2024

@alitoshmatov please complete the checklist and apply here so we can get you paid and close this one.

Copy link

melvin-bot bot commented Apr 9, 2024

Payment Summary

Upwork Job

BugZero Checklist (@kadiealexander)

  • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1772808192831074304/hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@kadiealexander
Copy link
Contributor

Bumped @alitoshmatov here.

@melvin-bot melvin-bot bot added the Overdue label Apr 11, 2024
@alitoshmatov
Copy link
Contributor

  • The PR that introduced the bug has been identified. Link to the PR: feat: policy add distance rate #38035
  • The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment: https://github.com/Expensify/App/pull/38035/files#r1561280352
  • A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: No need
  • Determine if we should create a regression test for this bug. No need

@melvin-bot melvin-bot bot removed the Overdue label Apr 11, 2024
@kadiealexander
Copy link
Contributor

@alitoshmatov I've sent an Upwork contract, please accept!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Internal Requires API changes or must be handled by Expensify staff
Projects
No open projects
Archived in project
Development

No branches or pull requests

7 participants