Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown distance rate shown during track expense that cause an error #56343

Open
4 of 8 tasks
IuliiaHerets opened this issue Feb 4, 2025 · 2 comments
Open
4 of 8 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2

Comments

@IuliiaHerets
Copy link

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: v9.0.94-1
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: #56146
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team
Device used: Windows 10 / Chrome, Samsung s10/ Chrome, Samsung s10/ Android 12
App Component: Other

Action Performed:

  1. Navigate to https://staging.new.expensify.com
  2. Log in a new user and choose track and budget expense and finish onboarding process
  3. Go to self DM
  4. Click + > Track expense > Distance
  5. Enter waypoints > Next
  6. On confirmation page, Notice the rate
  7. Click Track expense
  8. Click Categorize it from the whisper
  9. Select workspace, then category and submit it
  10. Notice the error caused by unknown rate from step 6.

Expected Result:

The generated rate should on the list of rates if it is a default rate and will not cause any error during track expense flow.

Actual Result:

There is unknown generated rate for distance track expense that cause an error

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6733167_1738675108763.bandicam_2025-02-04_15-16-46-898.mp4

View all open jobs on GitHub

@IuliiaHerets IuliiaHerets added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Feb 4, 2025
Copy link

melvin-bot bot commented Feb 4, 2025

Triggered auto assignment to @joekaufmanexpensify (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.

@NJ-2020
Copy link
Contributor

NJ-2020 commented Feb 5, 2025

Proposal

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

Unknown distance rate shown during track expense that cause an error

What is the root cause of that problem?

When we do not have any workspace, then we categorize it, it will redirect us to workspace upgrade step which will workspace for us

key: CONST.REPORT_DETAILS_MENU_ITEM.SETTINGS,
translationKey: 'actionableMentionTrackExpense.categorize',
icon: Expensicons.Folder,
isAnonymousAction: false,
shouldShowRightIcon: true,
action: () => {
createDraftTransactionAndNavigateToParticipantSelector(iouTransactionID, actionReportID, CONST.IOU.ACTION.CATEGORIZE, actionableWhisperReportActionID);

App/src/libs/ReportUtils.ts

Lines 8782 to 8784 in 27780d5

if (filteredPolicies.length === 0 || filteredPolicies.length > 1) {
Navigation.navigate(ROUTES.MONEY_REQUEST_UPGRADE.getRoute(actionName, CONST.IOU.TYPE.SUBMIT, transactionID, reportID));
return;

<UpgradeIntro
feature={feature}
onUpgrade={() => {
const policyData = Policy.createWorkspace('', false, '', undefined, CONST.ONBOARDING_CHOICES.TRACK_WORKSPACE);

And inside the createWorkspace function we will create the workspace using the default rates using buildOptimisticDistanceRateCustomUnits function which cause this error because the generated rate doesn't exist
https://github.com/Expensify/App/blob/27780d5a3c15ce3141d6ed3035cb4ed218f8f265/src/libs/actions/Policy/Policy.ts#L2037-L2047C64
function buildPolicyData(
policyOwnerEmail = '',
makeMeAdmin = false,
policyName = '',
policyID = generatePolicyID(),
expenseReportId?: string,
engagementChoice?: OnboardingPurpose,
currency = '',
file?: File,
shouldAddOnboardingTasks = true,
) {
const workspaceName = policyName || generateDefaultWorkspaceName(policyOwnerEmail);
const {customUnits, customUnitID, customUnitRateID, outputCurrency} = buildOptimisticDistanceRateCustomUnits(currency);

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

When creating the workspace we need to pass new param i.e transactionID (for the transaction draft id), and when creating the custom distance rate for the policy data we can use the DistanceRequestUtils.getRateForP2P function to return the transaction distance rate or the default distance rate

function buildOptimisticDistanceRateCustomUnits(reportCurrency?: string, transactionID?: string): OptimisticCustomUnits {
    const currency = reportCurrency || (allPersonalDetails?.[sessionAccountID]?.localCurrencyCode ?? CONST.CURRENCY.USD);
    const transaction = getTransaction(transactionID);
    const distanceRate = DistanceRequestUtils.getRateForP2P(currency, transaction)
    const customUnitID = generateCustomUnitID();
    const customUnitRateID = generateCustomUnitID();

    const customUnits: Record<string, CustomUnit> = {
        [customUnitID]: {
            customUnitID,
            name: CONST.CUSTOM_UNITS.NAME_DISTANCE,
            attributes: {
                unit: CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES,
            },
            rates: {
                [customUnitRateID]: {
                    customUnitRateID,
                    name: CONST.CUSTOM_UNITS.DEFAULT_RATE,
                    rate: distanceRate.rate,

The full code can be found in this test branch

And we need BE changes and pass custom distance rates

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

N/A UI bug

What alternative solutions did you explore? (Optional)

After creating the workspace, we can check if the policy custom distance rate is different from the transaction.comments.customUnits distance rate, then we will change the policy distance rate by calling UpdatePolicyDistanceRateValue function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2
Projects
None yet
Development

No branches or pull requests

3 participants