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-07-10] [$250] Workspace's default currency isn't showing when submitting a request #42597

Closed
6 tasks done
m-natarajan opened this issue May 24, 2024 · 27 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 External Added to denote the issue can be worked on by a contributor

Comments

@m-natarajan
Copy link

m-natarajan commented May 24, 2024

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.4.75-0
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: @dukenv0307
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1716540568640839

Action Performed:

  1. Create a new WS
  2. Change the currency of the workspace
  3. Go to the WS chat
  4. Tapping on the plus icon > Submit expense
  5. Notice the currency in amount step

Expected Result:

The default currency in the amount step should be the WS currency if we submit an expense in the WS chat.

Actual Result:

The default currency in the amount step isn't the WS currency

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

Add any screenshot/video evidence

Recording.121.mp4
Screen.Recording.2024-05-24.at.15.51.19.mov

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01ce85c0267e9bbc85
  • Upwork Job ID: 1795970316320600064
  • Last Price Increase: 2024-06-06
  • Automatic offers:
    • fedirjh | Reviewer | 102671509
    • ShridharGoel | Contributor | 102671511
Issue OwnerCurrent Issue Owner: @puneetlath
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels May 24, 2024
Copy link

melvin-bot bot commented May 24, 2024

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

@dukenv0307
Copy link
Contributor

I'm happy to take over this issue as C+ since I'm the reporter for this bug and have more context in this bug.

@nkdengineer
Copy link
Contributor

Proposal

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

The default currency in the amount step isn't the WS currency

What is the root cause of that problem?

When we init money request, we always set the default currency as the local currency of the user

currency: currentUserPersonalDetails.localCurrencyCode ?? CONST.CURRENCY.USD,

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

We should prioritize the policy's currency first instead of user's local currency

currency: policy?.outputCurrency ?? currentUserPersonalDetails.localCurrencyCode ?? CONST.CURRENCY.USD,

currency: currentUserPersonalDetails.localCurrencyCode ?? CONST.CURRENCY.USD,

What alternative solutions did you explore? (Optional)

NA

@ShridharGoel
Copy link
Contributor

Proposal

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

Policy currency is not being used when adding a money request and in teachers unite. Also, when workspace is made using iou report, then report currency is not being used.

What is the root cause of that problem?

Policy currency is not being used in initMoneyrequest:

currency: currentUserPersonalDetails.localCurrencyCode ?? CONST.CURRENCY.USD,

Also, policy currency is not being used in TeachersUnite:

outputCurrency: allPersonalDetails?.[sessionAccountID]?.localCurrencyCode ?? CONST.CURRENCY.USD,

Then, there's one more bug. When creating a workspace using report, the report's currency should be set as the default for the workspace but that is not happening as of now.

App/src/libs/actions/Policy.ts

Lines 2039 to 2040 in 525ad6f

function buildOptimisticCustomUnits(): OptimisticCustomUnits {
const currency = allPersonalDetails?.[sessionAccountID]?.localCurrencyCode ?? CONST.CURRENCY.USD;

Just the localCurrencyCode is being used.

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

We should use policy?.outputCurrency in the optimistic data when initing the money request:

Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${newTransactionID}`, {
    amount: 0,
    comment,
    created,
    currency: policy?.outputCurrency ?? currentUserPersonalDetails.localCurrencyCode ?? CONST.CURRENCY.USD,
    iouRequestType,
    reportID,
    transactionID: newTransactionID,
    isFromGlobalCreate,
    merchant: CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT,
    splitPayerAccountIDs: [currentUserPersonalDetails.accountID],
});

Update it in TeachersUnite.ts:

const optimisticData: OnyxUpdate[] = [
{
    onyxMethod: Onyx.METHOD.SET,
    key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
    value: {
        id: policyID,
        isPolicyExpenseChatEnabled: true,
        type: CONST.POLICY.TYPE.CORPORATE,
        name: policyName,
        role: CONST.POLICY.ROLE.USER,
        owner: sessionEmail,
        outputCurrency: getPolicy(policy)?.outputCurrency ?? allPersonalDetails?.[sessionAccountID]?.localCurrencyCode ?? CONST.CURRENCY.USD,
        employeeList: {
            [sessionEmail]: {
                role: CONST.POLICY.ROLE.USER,
                errors: {},
            },
        },
        pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
    },
},

Pass currency via iouReport:

const {customUnits, customUnitID, customUnitRateID} = buildOptimisticCustomUnits(iouReport.currency);

Now, it can be used in buildOptimisticCustomUnits:

function buildOptimisticCustomUnits(reportCurrency?: string): OptimisticCustomUnits {
    const currency = reportCurrency ?? allPersonalDetails?.[sessionAccountID]?.localCurrencyCode ?? CONST.CURRENCY.USD;
.....

@melvin-bot melvin-bot bot added the Overdue label May 27, 2024
Copy link

melvin-bot bot commented May 27, 2024

@puneetlath Whoops! This issue is 2 days overdue. Let's get this updated quick!

Copy link

melvin-bot bot commented May 29, 2024

@puneetlath Huh... This is 4 days overdue. Who can take care of this?

@puneetlath puneetlath added the External Added to denote the issue can be worked on by a contributor label May 30, 2024
@melvin-bot melvin-bot bot changed the title Workspace's default currency isn't showing when submitting a request [$250] Workspace's default currency isn't showing when submitting a request May 30, 2024
Copy link

melvin-bot bot commented May 30, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label May 30, 2024
Copy link

melvin-bot bot commented May 30, 2024

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

@melvin-bot melvin-bot bot removed the Overdue label May 30, 2024
@fedirjh
Copy link
Contributor

fedirjh commented Jun 3, 2024

I'm happy to take over this issue as C+ since I'm the reporter for this bug and have more context in this bug.

@dukenv0307 Are you still interested in taking this over? or should I proceed with my review ?

@dukenv0307
Copy link
Contributor

@fedirjh Pls go ahead, you already got assigned to this issue. Thank you

Copy link

melvin-bot bot commented Jun 6, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot melvin-bot bot added the Overdue label Jun 6, 2024
Copy link

melvin-bot bot commented Jun 6, 2024

@puneetlath, @fedirjh Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@puneetlath
Copy link
Contributor

What's the status of this issue?

Copy link

melvin-bot bot commented Jun 7, 2024

@puneetlath @fedirjh 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!

@fedirjh
Copy link
Contributor

fedirjh commented Jun 10, 2024

Thank you @nkdengineer and @ShridharGoel for the proposals. It seems that @ShridharGoel's proposal effectively resolves all instances of this issue. Therefore, I suggest we proceed with it.

Let's proceed with @ShridharGoel's proposal

🎀 👀 🎀 C+ reviewed

@melvin-bot melvin-bot bot removed the Overdue label Jun 10, 2024
Copy link

melvin-bot bot commented Jun 10, 2024

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

@nkdengineer
Copy link
Contributor

@fedirjh

Two additional cases in the selected proposal aren't bugs.

For both case TeachersUnite.ts and buildOptimisticCustomUnits, we're creating a new policy so it's expected that the default currency will be the localCurrencyCode of user.

@fedirjh
Copy link
Contributor

fedirjh commented Jun 10, 2024

we're creating a new policy so it's expected that the default currency will be the localCurrencyCode of user.

@nkdengineer We are creating new policy chats, rather than new policies. Therefore, it is expected for the chat created within a policy to use the same currency.

@nkdengineer
Copy link
Contributor

@fedirjh Let see this case TeachersUnite.ts

outputCurrency: allPersonalDetails?.[sessionAccountID]?.localCurrencyCode ?? CONST.CURRENCY.USD,

and createWorkspaceFromIOUPayment

const {customUnits, customUnitID, customUnitRateID} = buildOptimisticCustomUnits();

Both cases we're generating a new policy and create new policy chats with the optimistic policy so the new policy chats always have the same currency with the policy.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jun 10, 2024
Copy link

melvin-bot bot commented Jun 10, 2024

📣 @fedirjh 🎉 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

Copy link

melvin-bot bot commented Jun 10, 2024

📣 @ShridharGoel 🎉 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 melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Jun 10, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Jun 20, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jul 3, 2024
@melvin-bot melvin-bot bot changed the title [$250] Workspace's default currency isn't showing when submitting a request [HOLD for payment 2024-07-10] [$250] Workspace's default currency isn't showing when submitting a request Jul 3, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jul 3, 2024
Copy link

melvin-bot bot commented Jul 3, 2024

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

Copy link

melvin-bot bot commented Jul 3, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.3-7 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-07-10. 🎊

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

Copy link

melvin-bot bot commented Jul 3, 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:

  • [@fedirjh] The PR that introduced the bug has been identified. Link to the PR:
  • [@fedirjh] 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:
  • [@fedirjh] 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:
  • [@fedirjh] Determine if we should create a regression test for this bug.
  • [@fedirjh] 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.
  • [@puneetlath] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jul 10, 2024
@fedirjh
Copy link
Contributor

fedirjh commented Jul 10, 2024

BugZero Checklist:

  • Link to the PR: There was no PR that caused this bug. Instead, it seems to be more of a feature request than an actual bug.
  • Link to comment: N/A
  • Link to discussion: N/A
  • Determine if we should create a regression test for this bug: Yes

Regression Test Proposal

1. Navigate to the settings of any Workspace.
2. Modify the currency for that particular Workspace.
3. Access the Workspace chat dedicated to expense reports.
4. Click on the plus icon and proceed to submit an expense.
5. Confirm that the currency displayed in the amount step matches the updated value from Step 2.
  • Do we agree 👍 or 👎

@puneetlath
Copy link
Contributor

Payment summary:

Regression test: https://github.com/Expensify/Expensify/issues/412084

Thanks everyone!

@JmillsExpensify
Copy link

$250 approved for @fedirjh

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 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

7 participants