Skip to content

[Due for payment 2025-11-19] [$250] Add more report fields for optimistic report names #68695

Closed

Description

@neil-marcellini

Problem

As described in the parent issue, we currently do not support optimistic report name computation for several formula parts referencing basic report fields. These parts are listed below.

{report:id} – Base62 report ID
{report:status} – Report status
{report:expensescount} – Number of expenses in report

Solution

Please add support for these report formula parts in the optimistic computation within App.

Here is the current back-end C++ implementation, which you will likely find useful for proposals.

report:id
    if (partName == "id") {
        return Report::formatIDAsBase62(reportID);
    }
string Report::formatIDAsBase62(int64_t id)
{
    string base62 = Num::asBase62String(id);
    string padding(11 - base62.size(), '0');
    return 'R' + padding + base62;
}

string Num::asBase62String(int64_t from)
{
    if (from < 0) {
        throw out_of_range("Negative values not supported");
    }

    string result = "00000000000";
    size_t ptr = 10;
    while (from) {
        result[ptr--] = base62alphabet[from % 62];
        from /= 62;
    }

    for (ptr = 0; ptr < 10; ptr++) {
        if (result[ptr] != '0') {
            break;
        }
    }

    return result.substr(ptr);
}

const char* Num::base62alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
report:status
    if (partName == "status") {
        const Report::statuses status = static_cast<Report::statuses>(reportJSON.getIntMemberWithDefault("status"));
        return Report::STATUSES[status];
    }

const char* Report::STATUSES[Report::STATUS_NUM_STATUSES] = {
    "Open",
    "Processing",
    "Archived",
    "Approved",
    "Reimbursed",
};
report:expensescount

I have created an internal issue to start returning this field to NewDot. We will return the transactions count field to Onyx and then App needs to optimistically update this field whenever a transaction is added, deleted, or moved away from a report.

    if (partName == "expensescount") {
        return to_string(reportJSON.getIntMemberWithDefault("transactionCount"));
    }

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021957525358844302093
  • Upwork Job ID: 1957525358844302093
  • Last Price Increase: 2025-09-11
Issue OwnerCurrent Issue Owner: @
Issue OwnerCurrent Issue Owner: @
Issue OwnerCurrent Issue Owner: @strepanier03

Activity

  1. changed the title [-]Add more report fields for optimistic report names[/-] [+][$250] Add more report fields for optimistic report names[/+] on Aug 18, 2025
  2. melvin-bot commented on Aug 18, 2025

    @melvin-bot
  3. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Aug 18, 2025
  4. melvin-bot commented on Aug 18, 2025

    @melvin-bot

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

  5. lorretheboy commented on Aug 18, 2025

    @lorretheboy
    Contributor

    Proposal

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

    Add more report fields for optimistic report names

    What is the root cause of that problem?

    Improvement

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

    Add new util functions (May have some minor update/optimization during PR phase)

    /**
     * Format a report ID to Base62 format
     */
    function formatReportID(reportID: string | undefined): string {
        if (!reportID) {
            return '';
        }
    
        const numericReportID = parseInt(reportID, 10);
        if (Number.isNaN(numericReportID)) {
            return '';
        }
    
        return getBase62ReportID(numericReportID);
    }
    
    /**
     * Format a report status number to human-readable string
     */
    function formatReportStatus(statusNum: number | undefined): string {
        if (statusNum === undefined) {
            return '';
        }
    
        return getHumanReadableStatus(statusNum);
    }
    
    /**
     * Get the count of expenses (transactions) in a report
     */
    // Can update to return number if needed
    function formatExpensesCount(reportID: string | undefined): string {
        if (!reportID) {
            return '0';
        }
    
        const transactions = getReportTransactions(reportID);
        if (!transactions) {
            return '0';
        }
    
        // Filter out partial transactions (incomplete/draft transactions)
        const completeTransactions = transactions.filter((transaction) => !isPartialTransaction(transaction));
        return completeTransactions.length.toString();
    }

    Add new handler here

            case 'id':
                return formatReportID(report.reportID);
            case 'status':
                return formatReportStatus(report.statusNum);
            case 'expensescount':
                return formatExpensesCount(report.reportID);

    App/src/libs/Formula.ts

    Lines 243 to 261 in 869b6ad

    switch (field.toLowerCase()) {
    case 'type':
    return formatType(report.type);
    case 'startdate':
    return formatDate(getOldestTransactionDate(report.reportID), format);
    case 'total':
    return formatAmount(report.total, getCurrencySymbol(report.currency ?? '') ?? report.currency);
    case 'currency':
    return report.currency ?? '';
    case 'policyname':
    case 'workspacename':
    return policy?.name ?? '';
    case 'created':
    // Backend will always return at least one report action (of type created) and its date is equal to report's creation date
    // We can make it slightly more efficient in the future by ensuring report.created is always present in backend's responses
    return formatDate(getOldestReportActionDate(report.reportID), format);
    default:
    return part.definition;
    }

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

    Add new test cases in FormulaTest.ts

    What alternative solutions did you explore? (Optional)

    NA

    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.

  6. elizhabiboullah commented on Aug 18, 2025

    @elizhabiboullah

    Proposal

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

    Report titles that use formula fields are only partially supported by the offline-first optimistic name generator

    What is the root cause of that problem?

    Improvement

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

    Add placeholder support in

    function populateOptimisticReportFormula(formula: string, report: OptimisticExpenseReport, policy: OnyxEntry<Policy>): string {

    • {report:id} -> Use
      export default function getBase62ReportID(reportID: number): string {
    • {report:expensescount} -> Count non-deleted report transactions via existing report → transactions helpers
    • {report:reimbursable} / {report:nonreimbursable} -> Use
      function getMoneyRequestSpendBreakdown(report: OnyxInputOrEntry<Report>, searchReports?: SearchReport[]): SpendBreakdown {
      and format with convertToDisplayString(amount, report.currency)
      function convertToDisplayString(amountInCents = 0, currency: string = CONST.CURRENCY.USD): string {

    the title field source is already wired

    getTitleReportField()

    App/src/libs/ReportUtils.ts

    Lines 3871 to 3873 in fa220bd

    function getTitleReportField(reportFields: Record<string, PolicyReportField>) {
    return Object.values(reportFields).find((field) => isReportFieldOfTypeTitle(field));
    }
    and getReportFieldsByPolicyID()

    App/src/libs/ReportUtils.ts

    Lines 3895 to 3897 in fa220bd

    function getReportFieldsByPolicyID(policyID: string | undefined): Record<string, PolicyReportField> {
    if (!policyID) {
    return {};

    are used when building optimistic expense reports and empty reports:

    expenseReport.reportName = populateOptimisticReportFormula(titleReportField.defaultValue, expenseReport, policy);

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

    N/A

  7. github-actions commented on Aug 18, 2025

    @github-actions
    Contributor

    ⚠️ @elizhabiboullah Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).

  8. sofi-a commented on Aug 18, 2025

    @sofi-a
    Contributor

    🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.

  9. 72 remaining items

  10. melvin-bot commented on Nov 27, 2025

    @melvin-bot

    @parasharrajat 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

  11. melvin-bot commented on Dec 3, 2025

    @melvin-bot

    @parasharrajat Eep! 4 days overdue now. Issues have feelings too...

  12. strepanier03 commented on Dec 4, 2025

    @strepanier03
    Contributor

    Payment summary

  13. strepanier03 commented on Dec 4, 2025

    @strepanier03
    Contributor

    I paid the Upwork contract and closed it. Closing GH now since paying via Newdot is the last step.

  14. parasharrajat commented on Dec 19, 2025

    @parasharrajat
    Member

    Payment requested as per #68695 (comment)

  15. twisterdotcom commented on Dec 19, 2025

    @twisterdotcom
    Contributor

    @parasharrajat has submitted payment for this report on ND here.

    SO: https://stackoverflowteams.com/c/expensify/questions/7582

    Zapier Logs Run ID: 00040eee-ccb9-a5c5-830b-d21ca757a244
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.DailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions