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.36k stars 2.79k forks source link

[$250] Unable to resolve duplicates on one-expense reporrts #49793

Open m-natarajan opened 4 days ago

m-natarajan commented 4 days 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: 9.0.40-1 Reproducible in staging?: Y Reproducible in production?: Y 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: @JmillsExpensify Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1727339112704349

Action Performed:

  1. Create a new workspace, upgrade to Control
  2. Make sure you’re on the duplicate detection beta
  3. Enabled delayed submission with a weekly frequency. Enable approvals (with you as the approver)
  4. Have user a submit a report, with the merchant McDonalds for $50. Approve the report
  5. Have the user create another expense report for the same merchant and amount (McDonalds and $50)
  6. Have the user submit the report

    Expected Result:

    The approver is able to resolve a duplicate

    Actual Result:

    The approver is unable to resolve the duplicate, as no resolve duplicate button appears

    Workaround:

    Unknown

    Platforms:

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

    • [x] Android: Native
    • [x] Android: mWeb Chrome
    • [x] iOS: Native
    • [x] iOS: mWeb Safari
    • [x] MacOS: Chrome / Safari
    • [x] MacOS: Desktop

Screenshots/Videos

CleanShot 2024-09-26 at 10 21 23@2x

Snip - (4) New Expensify - Google Chrome

Add any screenshot/video evidence

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021839321413603387914
  • Upwork Job ID: 1839321413603387914
  • Last Price Increase: 2024-09-26
Issue OwnerCurrent Issue Owner: @sobitneupane
melvin-bot[bot] commented 4 days ago

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

daledah commented 4 days ago

Edited by proposal-police: This proposal was edited at 2024-09-26 15:28:39 UTC.

Proposal

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

The approver is unable to resolve the duplicate, as no resolve duplicate button appears

What is the root cause of that problem?

New feature

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

  1. Create the function to detect if the expense report has the duplicate
function getDuplicatedReportID(reportID: string){
    return Object.values(allReportActions?.[`reportActions_${reportID}`] ?? {}).find(action=>{
        const transactionID = ReportActionsUtils.isMoneyRequestAction(action) && ReportActionsUtils.getOriginalMessage(action)?.IOUTransactionID
        if(!transactionID){
            return false;
        }
        return TransactionUtils.isDuplicate(transactionID)
    })?.childReportID
}
  1. In MoneyReportHeader get the duplicated report ID
    const duplicatedReportID = useMemo(()=>{
        return ReportUtils.getDuplicatedReportID(moneyRequestReport?.reportID ?? '')
    },[moneyRequestReport?.reportID])

And then show the Resolve duplicate button if duplicatedReportID is not undefined

                {duplicatedReportID && !shouldUseNarrowLayout && (
                        <Button
                            success
                            text='Resolve duplicates'
                            style={[styles.p0, styles.ml2]}
                            onPress={() => {
                                Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_PAGE.getRoute(duplicatedReportID, Navigation.getReportRHPActiveRoute()));
                            }}
                        />
                    )}

What alternative solutions did you explore? (Optional)

Result

https://github.com/user-attachments/assets/006ee995-0cb3-4f57-8bd5-73bbf7b2c81a

dannymcclain commented 4 days ago

One way we could handle this is by adding a Resolve duplicates button to the header, like so: image

cc @JmillsExpensify @Expensify/design

melvin-bot[bot] commented 4 days ago

Job added to Upwork: https://www.upwork.com/jobs/~021839321413603387914

melvin-bot[bot] commented 4 days ago

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

JmillsExpensify commented 4 days ago

Nice, I like that idea!

daledah commented 4 days ago

Updated proposal to fit with the new design

dubielzyk-expensify commented 3 days ago

Same. Looks good to me

shubham1206agra commented 3 days ago

Am I missing something or one expense should auto resolve duplicates? What are we marking duplicate against?

pecanoro commented 3 days ago

@shubham1206agra The duplicates might be in a different report

sobitneupane commented 11 hours ago

Thanks for the proposal @daledah

We should remove canUseDupeDetection check in

I am not sure how is the change related to this issue. Dupe Detection is behind beta and the function is serving the purpose.

Can you please add more details to the 2nd point in your proposal.

daledah commented 9 hours ago

@sobitneupane Thanks for your feedback, I updated the proposal to add more details and video result