Skip to content

[Due for payment 2025-08-26] [$250] Expense-Unreported per diem expense can be added to workspace chat without per diem but it fail #65402

Closed

Description

@jponikarchuk

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.74-9
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/6414912&group_by=cases:section_id&group_order=asc&group_id=389197
Email or phone of affected tester (no customers): sdohisdojsdionjo@gmail.com
Issue reported by: Applause Internal Team
Device used: Mac 15.5 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • 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. Submit two per diem expenses to the workspace chat A.
  4. Open the expense report.
  5. Click More > Delete > Delete the report.
  6. Go to workspace chat B.
  7. Click + > Create report.
  8. Click Add expense > Add unreported expense.
  9. Select the unreported per diem expense.
  10. Click Add to report.

Expected Result:

In Step 7, the unreported per diem expense should not appear in the list of unreported expense because the workspace does not have per diem rates.

Actual Result:

In Step 7, the unreported per diem expense appears in the list of unreported expense when the workspace does not have per diem rates.
In Step 8, after adding the unreported per diem expense to the report, the expense disappears and moves back to self DM. Hidden chat appears in LHN after it fails to move to the report.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021941191961149602900
  • Upwork Job ID: 1941191961149602900
  • Last Price Increase: 2025-07-04
Issue OwnerCurrent Issue Owner: @

Activity

  1. added
    Daily
    Bug
    on Jul 3, 2025
  2. melvin-bot commented on Jul 3, 2025

    @melvin-bot

    Triggered auto assignment to @garrettmknight (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. ryntgh commented on Jul 3, 2025

    @ryntgh
    Contributor

    Proposal

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

    Expense-Unreported per diem expense can be added to workspace chat without per diem but it fail

    What is the root cause of that problem?

    We only filters transactions by their reportID but doesn't check if per diem transactions are compatible with the target workspace's per diem policy

    function getUnreportedTransactions(transactions: OnyxCollection<Transaction>) {
    if (!transactions) {
    return [];
    }
    return Object.values(transactions || {}).filter((item) => item?.reportID === CONST.REPORT.UNREPORTED_REPORT_ID || item?.reportID === '');
    }

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

    We should modify the getUnreportedTransactions function to filter out per diem transactions when the target workspace doesn't support per diem expenses

        function getUnreportedTransactions(transactions: OnyxCollection<Transaction>) {
            if (!transactions) {
                return [];
            }
            return Object.values(transactions || {}).filter((item) => {
                const isUnreported = item?.reportID === CONST.REPORT.UNREPORTED_REPORT_ID || item?.reportID === '';
                if (!isUnreported) {
                    return false;
                }
    
                if (isPerDiemRequest(item)) {
                    return canSubmitPerDiemExpenseFromWorkspace(policy);
                }
    
                return true;
            });
        }

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

    We could create test for getUnreportedTransactions if needed

    What alternative solutions did you explore? (Optional)

    Instead of modifying the selector function itself, we could keep the selector pure and add the per diem filtering logic using useMemo

        const [allUnreportedTransactions = []] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {
            selector: (_transactions) => getUnreportedTransactions(_transactions),
            initialValue: [],
            canBeMissing: true,
        });
    
        const transactions = useMemo(() => {
            return allUnreportedTransactions.filter((transaction) => {
                if (isPerDiemRequest(transaction)) {
                    return canSubmitPerDiemExpenseFromWorkspace(policy);
                }
                return true;
            });
        }, [allUnreportedTransactions, policy]);
  4. thelullabyy commented on Jul 3, 2025

    @thelullabyy
    Contributor

    Proposal

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

    In Step 7, the unreported per diem expense appears in the list of unreported expense when the workspace does not have per diem rates.
    In Step 8, after adding the unreported per diem expense to the report, the expense disappears and moves back to self DM. Hidden chat appears in LHN after it fails to move to the report.

    What is the root cause of that problem?

    We don't filter out the perdiem request if the workspace doesn't have per diem

    function getUnreportedTransactions(transactions: OnyxCollection<Transaction>) {
    if (!transactions) {
    return [];
    }
    return Object.values(transactions || {}).filter((item) => item?.reportID === CONST.REPORT.UNREPORTED_REPORT_ID || item?.reportID === '');
    }
    const [transactions = []] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {
    selector: (_transactions) => getUnreportedTransactions(_transactions),

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

    1. We should add the logic to filter out the perdiem transaction if the workspace doesn't have perdiem
    const canSubmitPerDiemExpense = useMemo(() => canSubmitPerDiemExpenseFromWorkspace(policy), [policy]);
    function getUnreportedTransactions(transactions: OnyxCollection<Transaction>) {
        if (!transactions) {
            return [];
        }
        return Object.values(transactions || {}).filter((item) => {
            const isUnReported = item?.reportID === CONST.REPORT.UNREPORTED_REPORT_ID || item?.reportID === '';
            if (!isUnReported) {
                return false;
            }
    
            if (isPerDiemRequest(item)) {
                return canSubmitPerDiemExpense;
            }
    
            return true;
        });
    }
    

    function getUnreportedTransactions(transactions: OnyxCollection<Transaction>) {

    1. Because the selector function depends on canSubmitPerDiemExpense, it's important to add this as a dependency here so the transactions can be updated when canSubmitPerDiemExpense is changed
    const [transactions = []] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {
        selector: (_transactions) => getUnreportedTransactions(_transactions),
        initialValue: [],
        canBeMissing: true,
    }, [canSubmitPerDiemExpense]);
    

    selector: (_transactions) => getUnreportedTransactions(_transactions),

    Optionally, we can add canSubmitPerDiemExpense as a parameter of getUnreportedTransactions function

    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.

  5. added
    External
    on Jul 4, 2025
  6. changed the title [-]Expense-Unreported per diem expense can be added to workspace chat without per diem but it fail[/-] [+][$250] Expense-Unreported per diem expense can be added to workspace chat without per diem but it fail[/+] on Jul 4, 2025
  7. melvin-bot commented on Jul 4, 2025

    @melvin-bot
  8. added
    Help Wanted
    on Jul 4, 2025
  9. melvin-bot commented on Jul 4, 2025

    @melvin-bot

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

  10. parasharrajat commented on Jul 4, 2025

    @parasharrajat
    Member

    @thelullabyy Please do not post duplicate proposals. It is against our contributing policy.

    @ryntgh's proposal looks good to me.

    🎀 👀 🎀 C+ reviewed

  11. 40 remaining items

  12. melvin-bot commented on Aug 28, 2025

    @melvin-bot

    Current assignee @parasharrajat is eligible for the External assigner, not assigning anyone new.

  13. removed
    Help Wanted
    on Aug 28, 2025
  14. melvin-bot commented on Aug 28, 2025

    @melvin-bot

    📣 @ryntgh You have been assigned to this job!
    Please apply to the Upwork job and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
    Once you apply to this job, your Upwork ID will be stored and you will be automatically hired for future jobs!
    Keep in mind: Code of Conduct | Contributing 📖

  15. garrettmknight commented on Aug 28, 2025

    @garrettmknight
    Contributor

    Payment Summary:

  16. ryntgh commented on Aug 29, 2025

    @ryntgh
    Contributor

    @garrettmknight Could you please send the offer to my account? I’m not able to apply to the job on my side

  17. garrettmknight commented on Sep 1, 2025

    @garrettmknight
    Contributor
  18. ryntgh commented on Sep 1, 2025

    @ryntgh
    Contributor

    Offer accepted, thanks!

  19. garrettmknight commented on Sep 2, 2025

    @garrettmknight
    Contributor

    Paid, closing

  20. parasharrajat commented on Sep 3, 2025

    @parasharrajat
    Member

    Payment requested as per #65402 (comment)

  21. quinthar commented on Sep 15, 2025

    @quinthar
    Contributor

    Approved $250 to @parasharrajat

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

Metadata

Metadata

Labels

BugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions