Skip to content

Reports-Report Title is not changed when change expense date if offline #73099

Closed

Description

@nlemma

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: v9.2.35-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #70627
Email or phone of affected tester (no customers): applausetester+ndk59@applause.expensifail.com
Issue reported by: Applause Internal Team
Device used: Windows 11 Home/Chrome
App Component: Money Requests

Action Performed:

Precondition: Use Expensifail account and add it to the beta.

  1. Open https://staging.new.expensify.com/
  2. Create new Workspace
  3. Navigate to Workspace settings > Reports
  4. Change 'default report title': Started {report:startdate} vs Ended {report:enddate}
  5. Navigate to Workspace chat
  6. Create report
  7. Go offline
  8. Create expense to report with dates different from the report creation date
  9. Create another expense with different date

Expected Result:

Expense report title is updated with Startdate and Enddate following the date of expenses

Actual Result:

Expense report title is not updated until device go back to online

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

Bug6980552_1761048958679.Change_date_expense_does_not_change_report_title_in_offline.mp4

View all open jobs on GitHub

Activity

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

    @melvin-bot

    Triggered auto assignment to @isabelastisser (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. abzokhattab commented on Oct 21, 2025

    @abzokhattab
    Contributor

    Proposal

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

    Report titles using {report:enddate} formula don't update when expense dates are changed while offline.

    What is the root cause of that problem?

    • The Formula.ts file lacks support for the {report:enddate} placeholder here
    • While {report:startdate} (oldest transaction date) is implemented, the corresponding {report:enddate} (newest transaction date) case is missing
    • When expenses are added/modified offline, the optimistic report name computation skips the {report:enddate} placeholder, leaving it unchanged

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

    In Formulas:

    • Add a getNewestTransactionDate function that returns the newest transaction date:
    function getNewestTransactionDate(reportID: string, context?: FormulaContext): string | undefined {
        if (!reportID) {
            return undefined;
        }
    
        const transactions = getReportTransactions(reportID);
        if (!transactions || transactions.length === 0) {
            return new Date().toISOString();
        }
    
        let newestDate: string | undefined;
    
        transactions.forEach((transaction) => {
            // Use updated transaction data if available and matches this transaction
            const currentTransaction = context?.transaction && transaction.transactionID === context.transaction.transactionID ? context.transaction : transaction;
    
            const created = getCreated(currentTransaction);
            if (!created) {
                return;
            }
            if (newestDate && created <= newestDate) {
                return;
            }
            if (isPartialTransaction(currentTransaction)) {
                return;
            }
            newestDate = created;
        });
    
        return newestDate;
    }
            case 'enddate':
                return formatDate(getNewestTransactionDate(report.reportID, context), format);

    optional instead of duplicating code of the getOldestTransactionDate and the new introduced function, we can add a shared function that takes getOldest: boolean param if true then it gets the oldest otherwise it gets the newest.

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

    In FormulaTest:

    • Add test cases for {report:enddate} computation with default format
    • Add test cases for {report:enddate} with custom date formats
    • Add test case for formulas using both {report:startdate} and {report:enddate} together
            test('should compute enddate formula using transactions', () => {
                const result = compute('{report:enddate}', mockContext);
                expect(result).toBe('2025-01-14'); // use newest transaction date (2025-01-14)
            });
    
            test('should compute enddate with custom format', () => {
                const result = compute('{report:enddate:MM/dd/yyyy}', mockContext);
                expect(result).toBe('01/14/2025'); // use newest transaction date with MM/dd/yyyy format
            });
    
            test('should compute enddate with short month format', () => {
                const result = compute('{report:enddate:dd MMM yyyy}', mockContext);
                expect(result).toBe('14 Jan 2025'); // use newest transaction date with dd MMM yyyy format
            });
    
            test('should compute formula with both startdate and enddate', () => {
                const result = compute('Started {report:startdate} vs Ended {report:enddate}', mockContext);
                expect(result).toBe('Started 2025-01-08 vs Ended 2025-01-14');
            });

    What alternative solutions did you explore? (Optional)

    NA

  4. mohammadjafarinejad commented on Oct 21, 2025

    @mohammadjafarinejad
    Contributor

    I think the beta flag is not enabled on the account. newExpensifyCustomReportNames is an explicitOnly flag, so it must be specifically enabled. Precondition Documentation.

  5. isabelastisser commented on Oct 27, 2025

    @isabelastisser
    Contributor

    I think this behavior is expected, given this precondition. Closing.

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions