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

Clicking Categorize this expense leads to enter an email or phone number page #52334

Closed
1 of 8 tasks
m-natarajan opened this issue Nov 11, 2024 · 6 comments
Closed
1 of 8 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2

Comments

@m-natarajan
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: 9.0.59-3
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?:
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @quinthar
Slack conversation (hyperlinked to channel name): ts_external_expensify_expense

Action Performed:

  1. Click the green fab > select Track expense
  2. Enter details and Click track expense
  3. Click Categorize it

Expected Result:

If user have Primary Workspace, the expense should be moved to that workspace, Categories list to select and If no workspace option to create a workspace

Actual Result:

List of workspaces displayed and option to create workspace and field to enter email , phone number displayed

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

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

Screenshots/Videos

Add any screenshot/video evidence
Recording.738.mp4

View all open jobs on GitHub

@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Nov 11, 2024
Copy link

melvin-bot bot commented Nov 11, 2024

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

@nkdengineer
Copy link
Contributor

nkdengineer commented Nov 11, 2024

Edited by proposal-police: This proposal was edited at 2024-11-11 20:08:32 UTC.

Proposal

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

List of workspaces displayed and option to create workspace and field to enter email , phone number displayed

What is the root cause of that problem?

New feature

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

We should add the primary workspace as a single participant by adding useEffect to MoneyRequestParticipantsSelector component

    useEffect(() => {
        if (isCategorizeAction) {
            const option = sections.find((option) => option.data.find((item) => item.policyID === activePolicyID))?.data.at(0);
            if (option) {
                addSingleParticipant(option);
            }
        }
    }, [isCategorizeAction, addSingleParticipant, sections]);

What alternative solutions did you explore? (Optional)

Screen.Recording.2024-11-12.at.03.07.34.mov

@Krishna2323
Copy link
Contributor

Proposal


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

Clicking Categorize this expense leads to enter an email or phone number page when there is a Primary Workspace

What is the root cause of that problem?

New feature

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


  • We should update createDraftTransactionAndNavigateToParticipantSelector to accept a new parameter activePolicyID.
  • We will get the activePolicy using getPolicy(activePolicyID); and policyExpenseChat using getPolicyExpenseChat(activePolicy?.ownerAccountID ?? -1, activePolicyID ?? '-1');.
  • Then we can conditionally add the participants array in the draft transaction.
  • We will create a condition for navigating to MONEY_REQUEST_STEP_CATEGORY when we have activePolicy && policyExpenseChat.
  • Lastly we will get the activePolicyID inside ReportActionItem & ReportDetailsPage using useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID) and pass it to createDraftTransactionAndNavigateToParticipantSelector.
  • Optional: We can also select the primary policy for share and submit action, for that we need have to make minor changes in the conditions in createDraftTransactionAndNavigateToParticipantSelector and in that cases we would navigate to MONEY_REQUEST_STEP_CONFIRMATION.
function createDraftTransactionAndNavigateToParticipantSelector(transactionID: string, reportID: string, actionName: IOUAction, reportActionID: string, activePolicyID?: string): void {
    const transaction = allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`] ?? ({} as Transaction);
    const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`] ?? ([] as ReportAction[]);
    const activePolicy = getPolicy(activePolicyID);

    if (!transaction || !reportActions) {
        return;
    }

    const linkedTrackedExpenseReportAction = Object.values(reportActions)
        .filter(Boolean)
        .find((action) => ReportActionsUtils.isMoneyRequestAction(action) && ReportActionsUtils.getOriginalMessage(action)?.IOUTransactionID === transactionID);

    const {created, amount, currency, merchant, mccGroup} = getTransactionDetails(transaction) ?? {};
    const comment = getTransactionCommentObject(transaction);
    const policyExpenseChat = getPolicyExpenseChat(activePolicy?.ownerAccountID ?? -1, activePolicyID ?? '-1');
    const isCategorize = actionName === CONST.IOU.ACTION.CATEGORIZE;

    IOU.createDraftTransaction({
        ...transaction,
        actionableWhisperReportActionID: reportActionID,
        linkedTrackedExpenseReportAction,
        linkedTrackedExpenseReportID: reportID,
        created,
        modifiedCreated: undefined,
        modifiedAmount: undefined,
        modifiedCurrency: undefined,
        amount,
        currency,
        comment,
        merchant,
        modifiedMerchant: '',
        mccGroup,
        ...(activePolicy && isCategorize && policyExpenseChat
            ? {
                  participants: [
                      {
                          selected: true,
                          accountID: 0,
                          isPolicyExpenseChat: true,
                          reportID: policyExpenseChat?.reportID,
                          policyID: activePolicy?.id,
                          searchText: activePolicy?.name,
                      },
                  ],
              }
            : {}),
    } as Transaction);

    const filteredPolicies = Object.values(allPolicies ?? {}).filter(
        (policy) => policy && policy.type !== CONST.POLICY.TYPE.PERSONAL && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
    );

    if (isCategorize && activePolicy && policyExpenseChat) {
        Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(actionName, CONST.IOU.TYPE.SUBMIT, transactionID, policyExpenseChat?.reportID));
        return;
    }
    if (actionName === CONST.IOU.ACTION.SUBMIT || (allPolicies && filteredPolicies.length > 0)) {
        Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(CONST.IOU.TYPE.SUBMIT, transactionID, reportID, undefined, actionName));
        return;
    }

    return createDraftWorkspaceAndNavigateToConfirmationScreen(transactionID, actionName);
}

What alternative solutions did you explore? (Optional)

Result

@melvin-bot melvin-bot bot added the Overdue label Nov 14, 2024
Copy link

melvin-bot bot commented Nov 15, 2024

@VictoriaExpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@VictoriaExpensify
Copy link
Contributor

There's been a fair bit of internal discussion on this but I want to make sure we're not doubling up. Posted here to find out if this is already being worked on elsewhere

@melvin-bot melvin-bot bot removed the Overdue label Nov 18, 2024
@trjExpensify
Copy link
Contributor

Yep, being worked on here. Closing!

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

5 participants