Skip to content

[Due for payment 2025-06-05] [Due for payment 2025-05-20] [$250] Per diem - Confirmation page shows per diem confirm page when it is a manual expense #59499

Closed

Description

@vincdargento

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: 9.1.22-1
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Yes, reproducible on both
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): applausetester+3m03i9@applause.expensifail.com
Issue reported by: Applause Internal Team
Device used: Mac 15.3 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • Log in with Expensifail accounts.
  • Workspace A has Per diem rates.
  • Workspace B does not have Per diem rates.
  1. Go to staging.new.expensify.com
  2. Go to workspace chat A.
  3. Click + > Submit expense > Per diem.
  4. Select country, time and subrate and submit per diem expense on the confirmation page.
  5. Go to workspace chat B.
  6. Click + > Submit expense > Manual.
  7. Enter amount > Next.

Expected Result:

The confirmation page will be manual expense confirmation page.

Actual Result:

The confirmation page shows per diem confirmation page when it is a manual expense.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

bug.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021907347910355058805
  • Upwork Job ID: 1907347910355058805
  • Last Price Increase: 2025-04-23
  • Automatic offers:
    • ishakakkad | Contributor | 107051841
Issue OwnerCurrent Issue Owner: @dylanexpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Apr 1, 2025
  2. melvin-bot commented on Apr 1, 2025

    @melvin-bot

    Triggered auto assignment to @dylanexpensify (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. daledah commented on Apr 1, 2025

    @daledah
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-04-01 23:37:26 UTC.

    Proposal

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

    The confirmation page shows per diem confirmation page when it is a manual expense.

    What is the root cause of that problem?

    Currently we are still saving the previous iouRequestType into the transaction,

    It leads to transactionRequestType here being per-diem even though this workspace is not enabled

    const transactionRequestType = useMemo(
    () => (transaction?.iouRequestType ?? shouldUseTab ? selectedTab : CONST.IOU.REQUEST_TYPE.MANUAL),
    [transaction?.iouRequestType, shouldUseTab, selectedTab],
    );

    So isPerDiemRequest in IOURequestStepConfirmation will be true and it'll show per diem confirm page

    const requestType = getRequestType(transaction);
    const isDistanceRequest = requestType === CONST.IOU.REQUEST_TYPE.DISTANCE;
    const isPerDiemRequest = requestType === CONST.IOU.REQUEST_TYPE.PER_DIEM;

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

    1. if it was per-diem before then we need to check if we are showing per-diem option
        const transactionRequestType = useMemo(
            () => {
                if(transaction?.iouRequestType === CONST.IOU.REQUEST_TYPE.PER_DIEM && !shouldShowPerDiemOption){
                    return shouldUseTab ? selectedTab : CONST.IOU.REQUEST_TYPE.MANUAL;
                } 
                return (transaction?.iouRequestType ?? shouldUseTab ? selectedTab : CONST.IOU.REQUEST_TYPE.MANUAL);
            },
            [transaction?.iouRequestType, shouldShowPerDiemOption, shouldUseTab, selectedTab],
        );
    
    1. We also have to wait for the transactionRequestType update to finish before calling the initMoneyRequest function here to make sure we will use the new value of transactionRequestType
        const [transaction, transactionMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${route?.params.transactionID || CONST.DEFAULT_NUMBER_ID}`);
     
       ...
       if (transaction?.reportID === reportID || isLoadingSelectedTab || isLoadingOnyxValue(transactionMetadata)) {
        return;
       }
    

    useFocusEffect(
    useCallback(() => {
    if (transaction?.reportID === reportID || isLoadingSelectedTab) {
    return;
    }
    initMoneyRequest(reportID, policy, isFromGlobalCreate, transaction?.iouRequestType, transactionRequestType);
    }, [transaction, policy, reportID, isFromGlobalCreate, transactionRequestType, isLoadingSelectedTab]),
    );

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    None

    What alternative solutions did you explore? (Optional)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Apr 2, 2025
  5. changed the title [-]Per diem - Confirmation page shows per diem confirm page when it is a manual expense[/-] [+][$250] Per diem - Confirmation page shows per diem confirm page when it is a manual expense[/+] on Apr 2, 2025
  6. melvin-bot commented on Apr 2, 2025

    @melvin-bot
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Apr 2, 2025
  8. melvin-bot commented on Apr 2, 2025

    @melvin-bot

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

  9. nkdengineer commented on Apr 2, 2025

    @nkdengineer
    Contributor

    Proposal

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

    The confirmation page shows per diem confirmation page when it is a manual expense.

    What is the root cause of that problem?

    When we start money request flow in a chat, we pass requestType as undefined

    onSelected: () => selectOption(() => startMoneyRequest(CONST.IOU.TYPE.SUBMIT, report?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)), true),

    App/src/libs/actions/IOU.ts

    Lines 868 to 869 in c3451e1

    default:
    Navigation.navigate(ROUTES.MONEY_REQUEST_CREATE.getRoute(CONST.IOU.ACTION.CREATE, iouType, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, reportID));

    In this page, the selectedTab is changed because now the per diem is hidden, resetIOUTypeIfChanged is triggered first.

    const resetIOUTypeIfChanged = useCallback(
    (newIOUType: IOURequestType) => {
    if (transaction?.iouRequestType === newIOUType) {
    return;
    }
    initMoneyRequest(reportID, policy, isFromGlobalCreate, transaction?.iouRequestType, newIOUType);

    Then the useFocusEffect here is triggered, but at this time, selectedTab is still perdiem. It's pending update here

    useFocusEffect(
    useCallback(() => {
    if (transaction?.reportID === reportID || isLoadingSelectedTab) {
    return;
    }
    initMoneyRequest(reportID, policy, isFromGlobalCreate, transaction?.iouRequestType, transactionRequestType);
    }, [transaction, policy, reportID, isFromGlobalCreate, transactionRequestType, isLoadingSelectedTab]),
    );

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

    We can update the selectTab to manual here if the last selected tab is per-diem and the current policy doesn't enable per-diem

    const policyPerDiemUnit = getPerDiemCustomUnit(policy);
    const doesCurrentPolicyPerDiemExist = !isEmptyObject(policyPerDiemUnit) && !!policyPerDiemUnit.enabled;
    const [selectedTab = CONST.TAB_REQUEST.SCAN] = useOnyx(`${ONYXKEYS.COLLECTION.SELECTED_TAB}${CONST.TAB.IOU_REQUEST_TYPE}`);
    
    onSelected: () => selectOption(() => {
        if (selectedTab === CONST.TAB_REQUEST.PER_DIEM && !doesCurrentPolicyPerDiemExist) {
            Tab.setSelectedTab(CONST.TAB.IOU_REQUEST_TYPE, CONST.IOU.REQUEST_TYPE.MANUAL);
        }
        startMoneyRequest(CONST.IOU.TYPE.SUBMIT, report?.reportID ?? String(CONST.DEFAULT_NUMBER_ID));
    }, true),
    

    onSelected: () => selectOption(() => startMoneyRequest(CONST.IOU.TYPE.SUBMIT, report?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)), true),

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    None

    What alternative solutions did you explore? (Optional)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  10. ishakakkad commented on Apr 5, 2025

    @ishakakkad
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-04-16 16:04:45 UTC.

    Proposal

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

    The confirmation page shows per diem confirmation page when it is a manual expense. This issue occurred for the workspaces where per-diem feature is disabled.

    What is the root cause of that problem?

    • We are saving the previous iouRequestType inside the transaction. And whenever create expense sidebar open it fetches the iouRequestType from transaction. Due to this transactionRequestType is per-diem even though currently selected workspace is not enabled.

    const transactionRequestType = useMemo(
    () => (transaction?.iouRequestType ?? shouldUseTab ? selectedTab : CONST.IOU.REQUEST_TYPE.MANUAL),
    [transaction?.iouRequestType, shouldUseTab, selectedTab],
    );

    • But here we reset the tab to manual due to below logic when page loads.

      const resetIOUTypeIfChanged = useCallback(
      (newIOUType: IOURequestType) => {
      if (transaction?.iouRequestType === newIOUType) {
      return;
      }
      initMoneyRequest(reportID, policy, isFromGlobalCreate, transaction?.iouRequestType, newIOUType);

    • But after resetIOUTypeIfChanged useFocusEffect is runs which reset the iouRequestType to perdiem again because of transactionRequestType has older value. So there is inconsistent between selected tab and Step confirmation sidebar.

    useFocusEffect(
    useCallback(() => {
    if (transaction?.reportID === reportID || isLoadingSelectedTab) {
    return;
    }
    initMoneyRequest(reportID, policy, isFromGlobalCreate, transaction?.iouRequestType, transactionRequestType);
    }, [transaction, policy, reportID, isFromGlobalCreate, transactionRequestType, isLoadingSelectedTab]),
    );

    • In confirmation page we fetch the iouRequestType from transaction which is perdiem so we can see per diem confirm page.

    const requestType = getRequestType(transaction);
    const isDistanceRequest = requestType === CONST.IOU.REQUEST_TYPE.DISTANCE;
    const isPerDiemRequest = requestType === CONST.IOU.REQUEST_TYPE.PER_DIEM;

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

    To fix this issue we can add new useFocusEffect here which will run whenever transactionRequestType is changed and call resetIOUTypeIfChanged() like below.
    Not only below logic is simple but by adding below logic we can make sure iouRequestType is always up to date and sync with the selected tab.

    This will not only solve the current issue but will solve issues we may face in future as well if we add any new tab which will be visible based on some settings.

    useFocusEffect(
            useCallback(() => {
                resetIOUTypeIfChanged(transactionRequestType);
            }, [resetIOUTypeIfChanged, transactionRequestType]),
        );
    

    Or modify existing hook here with following code

     useFocusEffect(
            useCallback(() => {
                if (isLoadingSelectedTab) {
                    return;
                }
                resetIOUTypeIfChanged(transactionRequestType);
            }, [resetIOUTypeIfChanged, transactionRequestType, isLoadingSelectedTab]),
        );
    

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    NA

    What alternative solutions did you explore? (Optional)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  11. melvin-bot commented on Apr 7, 2025

    @melvin-bot

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

  12. 61 remaining items

  13. dylanexpensify commented on May 28, 2025

    @dylanexpensify
    Contributor

    tackling today!

  14. dylanexpensify commented on May 29, 2025

    @dylanexpensify
    Contributor

    Payment summary:

    Contributor: @ishakakkad $250 via Upwork
    Contributor+: @getusha $250 via NewDot

    Please apply/request!

  15. dylanexpensify commented on May 29, 2025

    @dylanexpensify
    Contributor

    @getusha please complete checklist

  16. changed the title [-][Due for payment 2025-05-20] [$250] Per diem - Confirmation page shows per diem confirm page when it is a manual expense[/-] [+][Due for payment 2025-06-05] [Due for payment 2025-05-20] [$250] Per diem - Confirmation page shows per diem confirm page when it is a manual expense[/+] on May 29, 2025
  17. melvin-bot commented on May 29, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.53-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 2025-06-05. 🎊

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

  18. melvin-bot commented on May 29, 2025

    @melvin-bot

    @getusha @dylanexpensify @getusha The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  19. dylanexpensify commented on Jun 3, 2025

    @dylanexpensify
    Contributor

    Payment summary:

    Contributor: @ishakakkad $250 via Upwork
    Contributor+: @getusha $250 via NewDot

    Please apply/request!

  20. garrettmknight commented on Jul 17, 2025

    @garrettmknight
    Contributor

    $250 approved for @getusha

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.ExternalAdded to denote the issue can be worked on by a contributorWeeklyKSv2

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions