Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.47k stars 2.82k forks source link

Invoice - In search, Invoice doesn't displays merchant text "expense" #50794

Open IuliiaHerets opened 2 hours ago

IuliiaHerets commented 2 hours ago

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.0.49-0 Reproducible in staging?: Y Reproducible in production?: Y Issue reported by: Applause Internal Team

Action Performed:

Pre-condition:Keep invoice enabled in a workspace

  1. Go to https://staging.new.expensify.com/home

  2. Tap fab--send invoice

  3. Create an invoice

  4. Navigate to LHN -- Search

  5. Navigate to invoice section

  6. Note preview doesn't show merchant field text "expense"

  7. Tap on the invoice and note "expense" text in merchant field

Expected Result:

In search, Invoice must display merchant text "expense".

Actual Result:

In search, Invoice doesn't displays merchant text "expense".

Workaround:

Unknown

Platforms:

Screenshots/Videos

https://github.com/user-attachments/assets/8c1f7073-8c38-46a2-9c62-8a3b702cb52b

View all open jobs on GitHub

melvin-bot[bot] commented 2 hours ago

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

IuliiaHerets commented 2 hours ago

@JmillsExpensify FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

mkzie2 commented 1 hour ago

Proposal

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

In search, Invoice doesn't displays merchant text "expense".

What is the root cause of that problem?

Sometime when we create a send invoice, merchant param is an empty string then BE returns merchant as Expense.

I think the current problem here is the Expense merchant appears in REPORTPREVIEW action. That is how we're displaying merchant in other places like here, here and here

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

We should fix to not display Expense merchant in the report preview action. To do that we can add the same check that we use to display the merchant in other places

const shouldShowMerchant =
  !!formattedMerchant &&
  formattedMerchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT &&
  formattedMerchant !== CONST.TRANSACTION.DEFAULT_MERCHANT &&
  !(hasOnlyTransactionsWithPendingRoutes && !totalDisplaySpend);
const shouldShowSingleRequestMerchantOrDescription =
  numberOfRequests === 1 && (!!shouldShowMerchant || !!formattedDescription) && !(hasOnlyTransactionsWithPendingRoutes && !totalDisplaySpend);

https://github.com/Expensify/App/blob/e9de4f2b1d5d1ed8b1ab705cd1fb79dee42a95a5/src/components/ReportActionItem/ReportPreview.tsx#L351

What alternative solutions did you explore? (Optional)

When we create a send invoice, we can fallback merchant as CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT here

https://github.com/Expensify/App/blob/e9de4f2b1d5d1ed8b1ab705cd1fb79dee42a95a5/src/libs/actions/IOU.ts#L1871

NJ-2020 commented 1 hour ago

Proposal

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

Invoice - In search, Invoice doesn't displays merchant text "expense"

What is the root cause of that problem?

Right here if the merchant value is equal to Expense we return empty string https://github.com/Expensify/App/blob/e9de4f2b1d5d1ed8b1ab705cd1fb79dee42a95a5/src/libs/SearchUtils.ts#L85 merchant === CONST.TRANSACTION.DEFAULT_MERCHANT ? ''

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

We should remove this code: merchant === CONST.TRANSACTION.DEFAULT_MERCHANT ? ''

What alternative solutions did you explore? (Optional)

nyomanjyotisa commented 32 minutes ago

Proposal

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

Invoice - In search, Invoice doesn't displays merchant text "expense"

What is the root cause of that problem?

We don't display the merchant if the merchant is 'Expense' https://github.com/Expensify/App/blob/a59bbc3cf846c718ba40f0919fabb371c6dcd86d/src/libs/SearchUtils.ts#L85

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

If we need to display the merchant although it is Expense for Invoices we can update the following code https://github.com/Expensify/App/blob/a59bbc3cf846c718ba40f0919fabb371c6dcd86d/src/libs/SearchUtils.ts#L85

const formattedMerchant = merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT || (merchant === CONST.TRANSACTION.DEFAULT_MERCHANT && transactionItem.reportType != CONST.REPORT.TYPE.INVOICE) ? '' : merchant;

And update this to show the merchant column https://github.com/Expensify/App/blob/a59bbc3cf846c718ba40f0919fabb371c6dcd86d/src/libs/SearchUtils.ts#L119

return merchant !== '' && merchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT && !(merchant === CONST.TRANSACTION.DEFAULT_MERCHANT && item.reportType != CONST.REPORT.TYPE.INVOICE);

What alternative solutions did you explore? (Optional)

ALTERNATIVE 1 If we want to always display the merchant for all reportType change to the following

const formattedMerchant = merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT ? '' : merchant;
return merchant !== '' && merchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT;

ALTERNATIVE 2 Also the merchant set to Expense because the merchant param we pass to the API is empty string, if we want to set it to empty or (none) can can update the following code https://github.com/Expensify/App/blob/a59bbc3cf846c718ba40f0919fabb371c6dcd86d/src/libs/actions/IOU.ts#L3678

merchant: transaction?.merchant ?? CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT,