Skip to content

[HOLD for payment 2024-07-10] [$250] Workspace's default currency isn't showing when submitting a request #42597

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

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on May 24, 2024
  2. melvin-bot commented on May 24, 2024

    @melvin-bot

    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.

  3. dukenv0307 commented on May 24, 2024

    @dukenv0307
    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.

  4. nkdengineer commented on May 24, 2024

    @nkdengineer
    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

  5. ShridharGoel commented on May 25, 2024

    @ShridharGoel
    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;
    .....
    
  6. melvin-bot commented on May 27, 2024

    @melvin-bot

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

  7. melvin-bot commented on May 29, 2024

    @melvin-bot

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

  8. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on May 30, 2024
  9. 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[/+] on May 30, 2024
  10. melvin-bot commented on May 30, 2024

    @melvin-bot
  11. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on May 30, 2024
  12. 23 remaining items

  13. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Jul 3, 2024
  14. 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[/+] on Jul 3, 2024
  15. melvin-bot commented on Jul 3, 2024

    @melvin-bot

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

  16. melvin-bot commented on Jul 3, 2024

    @melvin-bot

    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:

  17. melvin-bot commented on Jul 3, 2024

    @melvin-bot

    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:
  18. fedirjh commented on Jul 10, 2024

    @fedirjh
    Contributor

    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 👎
  19. puneetlath commented on Jul 11, 2024

    @puneetlath
    Contributor

    Payment summary:

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

    Thanks everyone!

  20. JmillsExpensify commented on Jul 11, 2024

    @JmillsExpensify
    Contributor

    $250 approved for @fedirjh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions