Skip to content

Accounting - "Export to Sage Intacct" button only appears if the expense is opened #59801

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: 9.1.24-2
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: #59718
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Device used: Apple iPhone 12 Pro / Safari, Samsung Galaxy A52s 5G / Android 14
App Component: Other

Action Performed:

Precondition: Use a Gmail account that has at least one manual expense created, paid "Elsewhere", and connected to Sage Intacct after the creation of that expense.

  1. Navigate to https://staging.new.expensify.com/
  2. Open the workspace chat
  3. Open the expense

Expected Result:

The button should be visible for older expenses too.

Actual Result:

"Export to Sage Intacct" button only appears if the expense is opened. The button appears for expenses created after connecting to Sage.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6795796_1744099410845.Opening_expense_created_before_Sage.mp4

View all open jobs on GitHub

Activity

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

    @melvin-bot

    Triggered auto assignment to @RachCHopkins (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. FitseTLT commented on Apr 8, 2025

    @FitseTLT
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-04-08 22:13:17 UTC.

    Proposal

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

    Accounting - "Export to Sage Intacct" button only appears if the expense is opened

    What is the root cause of that problem?

    The canExport function we use to show the button here needs the expense report to calculate

    function canExport(report: Report, violations: OnyxCollection<TransactionViolation[]>, policy?: Policy) {
    const isExpense = isExpenseReport(report);
    const isExporter = policy ? isPrefferedExporter(policy) : false;
    const isApproved = isReportApproved({report});
    const isReimbursed = isSettled(report);
    const isClosed = isClosedReport(report);
    const hasAccountingConnection = hasAccountingConnections(policy);
    const connectedIntegration = getConnectedIntegration(policy);
    const syncEnabled = hasIntegrationAutoSync(policy, connectedIntegration);
    const hasViolations = hasAnyViolations(report.reportID, violations);
    if (isExpense && isExporter && hasAccountingConnection && !syncEnabled && !hasViolations) {
    return isApproved || isReimbursed || isClosed;
    }
    return false;

    but just after signing in or clearing cache the expense report will not be available until we open the expense report.

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

    We can use the report preview childStatus to calculate as a fallback

    function canExport(report: OnyxEntry<Report>, violations: OnyxCollection<TransactionViolation[]>, policy?: Policy, action) {
        const isExpense = isExpenseReport(report) || (isReportPreviewAction(action) && action.childType === 'expense');
        const isExporter = policy ? isPrefferedExporter(policy) : false;
        const isApproved = isReportApproved({report}) || action.childStatusNum === CONST.REPORT.STATUS_NUM.APPROVED;
        const isReimbursed = isSettled(report) || action.childStatusNum === CONST.REPORT.STATUS_NUM.REIMBURSED;
        const isClosed = isClosedReport(report) || action.childStatusNum === CONST.REPORT.STATUS_NUM.CLOSED;
        const hasAccountingConnection = hasAccountingConnections(policy);
        const connectedIntegration = getConnectedIntegration(policy);
        const syncEnabled = hasIntegrationAutoSync(policy, connectedIntegration);
        const hasViolations = hasAnyViolations(report?.reportID, violations);
        if (isExpense && isExporter && hasAccountingConnection && !syncEnabled && !hasViolations) {
            return isApproved || isReimbursed || isClosed;
        }
        return false;
    }
    

    Then we need to update getReportPreviewAction to pass the action param

    function getReportPreviewAction(
        violations: OnyxCollection<TransactionViolation[]>,
        report?: Report,
        policy?: Policy,
        transactions?: Transaction[],
        action,
    ): ValueOf<typeof CONST.REPORT.REPORT_PREVIEW_ACTIONS> {
        if (report && canSubmit(report, violations, policy)) {
            return CONST.REPORT.REPORT_PREVIEW_ACTIONS.SUBMIT;
        }
        if (report && canApprove(report, violations, policy, transactions)) {
            return CONST.REPORT.REPORT_PREVIEW_ACTIONS.APPROVE;
        }
        if (report && canPay(report, violations, policy)) {
            return CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY;
        }
        if ((report || action) && canExport(report, violations, policy, action)) {
            return CONST.REPORT.REPORT_PREVIEW_ACTIONS.EXPORT_TO_ACCOUNTING;
        }
        if (report && canReview(report, violations, policy)) {
            return CONST.REPORT.REPORT_PREVIEW_ACTIONS.REVIEW;
        }
    
        return CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW;
    }
    

    Then pass the report preview action

    return getReportPreviewAction(violations, iouReport, policy, transactions);

    Update this

    function canBeExported(report: OnyxEntry<Report>, action?: OnyxEntry<ReportAction>) {
        const statusNum = report?.statusNum ?? action?.childStatusNum;
        if (!statusNum) {
            return false;
        }
        const isCorrectState = [CONST.REPORT.STATUS_NUM.APPROVED, CONST.REPORT.STATUS_NUM.CLOSED, CONST.REPORT.STATUS_NUM.REIMBURSED].some((status) => status === statusNum);
        return (isExpenseReport(report) || (isReportPreviewAction(action) && action.childType === 'expense')) && isCorrectState;
    }
    

    then pass action as a second param where needed as in here
    And additionally we need to give the preview action childReportID as a fallback here

    const reportID = report?.reportID;

        const reportID = report?.reportID ?? action.childReportID;
    
    

    we will pass the report preview action as a prop to ExportWithDropdownMenu here

    BTW we will need the same fix applied for MoneyRequestReportPreviewContent too.

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

    if needed we can test getReportPreviewAction returns export action without passing the expense report but providing the appropriate report preview parent action

    What alternative solutions did you explore? (Optional)

  4. RachCHopkins commented on Apr 11, 2025

    @RachCHopkins
    Contributor

    This seems intentional to me and is similar to how it works now. You don't want a barrage of unexported expenses prompting export, some people use Expensify for years before connecting an accounting system - it would be awful if you suddenly had 5 years worth of expenses prompting an export despite not being interacted with.

    @mountiny what do you think the expected behaviour should be here?

  5. mountiny commented on Apr 11, 2025

    @mountiny
    Contributor

    Ah I dont have that much knowledge about this I will ask Jason

  6. JmillsExpensify commented on Apr 11, 2025

    @JmillsExpensify
    Contributor

    Ahhh that's a good point. I see what Rachael is saying. I think the real solution for that is eventually add a mark as exported and bulk option to do the same. In fact, I'm pretty certain this already exists, though in any case, I think we can probably just close this issue.

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

Metadata

Metadata

Assignees

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