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.33k stars 2.76k forks source link

[$250] [Mentions] Empty expense details and broken report when user is invited to combined report #48396

Open IuliiaHerets opened 1 week ago

IuliiaHerets commented 1 week 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.27-0 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: Exp https://expensify.testrail.io/index.php?/tests/view/4907185 Email or phone of affected tester (no customers): applausetester+kh050806@applause.expensifail.com Issue reported by: Applause Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. [User A] Submit an expense to User B (make sure User B has no unsettled expense with User A)
  3. [User A] Click on the expense preview in the main chat to go to combined report.
  4. [User A] Send a user mention containing User C
  5. [User A] Click Invite from the whisper message
  6. [User C] Open the invited expense report

Expected Result:

Actual Result:

Workaround:

Unknown

Platforms:

Screenshots/Videos

https://github.com/user-attachments/assets/b0e92856-5540-4911-9b2e-f8ac88043791

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021831652271737365741
  • Upwork Job ID: 1831652271737365741
  • Last Price Increase: 2024-09-12
Issue OwnerCurrent Issue Owner: @fedirjh
melvin-bot[bot] commented 1 week ago

Triggered auto assignment to @trjExpensify (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 1 week ago

@trjExpensify 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

trjExpensify commented 1 week ago

I don't get the glitch screen when repro'ing this, but I do see empty details in the one expense iouReport for the invited user, so it does seem broken:

image
trjExpensify commented 1 week ago

CC'ing @puneetlath for visibility as a mentions invite bug.

melvin-bot[bot] commented 1 week ago

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

melvin-bot[bot] commented 1 week ago

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

melvin-bot[bot] commented 4 days ago

@trjExpensify, @fedirjh Huh... This is 4 days overdue. Who can take care of this?

fedirjh commented 4 days ago

Awaiting on proposals

burczu commented 2 days ago

Hi, I’m Bartek from Callstack and I would like to investigate this issue.

melvin-bot[bot] commented 2 days ago

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

jacobkim9881 commented 2 days ago

Proposal

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

When invited to open expense preview, the report preview is broken.

What is the root cause of that problem?

https://github.com/Expensify/App/blob/52c0ccb5ab623a1056ecc8be569e0925cdfd07f5/src/pages/home/report/ReportActionsView.tsx#L162-L164 lastAction is false in the issue. When the user C invited, the user got this report action as a last action within report actions:

{
    "originalMessage": {
        "resolution": "invited"
    }
}

lastAction selects the invite resolution and the condition for checking create action passes the lastAction. As a result fake create report action is made and there are 2 report actions with actionName "CREATED" type :

//this the fake one
{
    "reportActionID": "2366733686483205217",
    "message": [
        {
            "type": "TEXT",
            "style": "strong",
            "text": "18284767"
        },
        {
            "type": "TEXT",
            "style": "normal",
            "text": " created this report"
        }
    ],
    "pendingAction": null,
    "actionName": "CREATED",
    "created": "2024-09-12 13:19:39.701",
    "actorAccountID": 18269034,
    "person": [
        {
            "type": "TEXT",
            "style": "strong",
            "text": "assa"
        }
    ]
} 
// And original one: 
{
    "reportActionID": "1609068092870573138",
    "message": [
        {
            "type": "TEXT",
            "style": "strong",
            "text": "cvj (jacobkim9881+65@gmail.com)"
        },
        {
            "type": "TEXT",
            "style": "normal",
            "text": " created this report"
        }
    ],
    "actionName": "CREATED",
    "created": "2024-09-11 14:53:15.735",
    "person": [
        {
            "type": "TEXT",
            "style": "strong",
            "text": "jacobkim9881+65@gmail.com"
        }
    ]
}

The reason fake report action with "CREATED" is for showing expense preview till having report actions from openReport API :

https://github.com/Expensify/App/blob/52c0ccb5ab623a1056ecc8be569e0925cdfd07f5/src/pages/home/report/ReportActionsView.tsx#L152

As there are 2 "CREATED" report actions, there 2 components that have 2 same background and same amount form so CSS is broken for 2 components too.

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

We can show better expense preview by defining lastAction. We should check lastAction is invited message or not :

const isInvitedMsg = isLastActionInvited ? true : false

If it is invited one then we edit lastAction and pass it into the condition :


const editedLastAction = isInvitedMsg ? allReportActions[allReportActions.length - 2] : lastAction;

if(!ReportActionsUtils.isCreatedAction(editedLastAction)) {

...

Then whenever report actions is shown at report screen that have a report action "invited" resolution, second last action will be chosen. It will not create fake report action.

What alternative solutions did you explore? (Optional)

N/A

jacobkim9881 commented 2 days ago

Hi, @fedirjh, I was trying to solve the issue. Can I upload a proposal?