Skip to content

[Due for payment 2025-07-14] [$250] Reports - After deleting expense and returning to "Chats" messages display fallback avatar. #63300

Closed

Description

@mitarachim

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.1.56-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: N/A
Email or phone of affected tester (no customers): ibellicotest+948@gmail.com
Issue reported by: Applause Internal Team
Device used: Motorola MotoG60 - Android 12 - Chrome / Windows 10 - Chrome
App Component: Search

Action Performed:

Prerequisite: Account has at least one workspace available.
Prerequisite 2: No expenses created yet.

  1. Open the Expensify app.
  2. Open any workspace chat.
  3. Submit a manual expense.
  4. Navigate to "Reports"
  5. Tap on the bookmark icon and select "Chats"
  6. Note that all the messages display the correct avatat.
  7. Tap on bookmark icon again and select "Expenses"
  8. Long tap on the just created expense and select it.
  9. Delete the expense.
  10. After the expense disappears, use device´s back button to return to "Chats"
  11. Note that now, all the messages display fallback avatar.

Expected Result:

All the messages on "Chats" section, should display the correct avatar in every moment.

Actual Result:

After deleting an expense on "Expenses" section and returning to "Chats" using the device´s back button, all the messages are displayed with fallback avatar.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6849237_1748914437977.Fallback.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021933156796042939339
  • Upwork Job ID: 1933156796042939339
  • Last Price Increase: 2025-06-12
  • Automatic offers:
    • nkdengineer | Contributor | 107692736
Issue OwnerCurrent Issue Owner: @zanyrenney

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jun 3, 2025
  2. melvin-bot commented on Jun 3, 2025

    @melvin-bot

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

  3. bernhardoj commented on Jun 3, 2025

    @bernhardoj
    Contributor

    Proposal

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

    It's not that after deleting expense, but after going from the empty expense tab back to the Chats tab, the avatar is shown with a fallback image.

    What is the root cause of that problem?

    The avatar is taken from the personal detail list collection.

    const {avatar, login, pendingFields, status, fallbackIcon} = personalDetails?.[actorAccountID ?? CONST.DEFAULT_NUMBER_ID] ?? {};

    However, after coming back from the empty expense report, the value is undefined. The value is retrieved from the onyx snapshot data, based on the current search hash.

    App/src/hooks/useOnyx.ts

    Lines 48 to 49 in 4142c94

    const useOnyx: OriginalUseOnyx = (key, options, dependencies) => {
    const {isOnSearch, currentSearchHash} = useSearchContext();

    The current search hash is updated every time the hash is updated.

    useEffect(() => {
    clearSelectedTransactions(hash);
    setCurrentSearchHash(hash);
    }, [hash, clearSelectedTransactions, setCurrentSearchHash]);

    This means that when switching between tabs (because a new search component is added), or updating the filter. However, when we navigate back using the browser/device back button, we simply pop the current search component and go back to the previous component. This doesn't trigger the above useEffect. So, the current search hash still hold the previous search hash, and since the previous search is an empty expense report, the personal details list is empty too.

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

    We need to update the search hash every time the screen changes, too. The simplest way to do this is to use a useFocusEffect.

    useFocusEffect(useCallback(() => {
        setCurrentSearchHash(hash);
    }, []));
    

    (we can update setCurrentSearchHash to ignore the call if the current search hash is the same as the passed hash)

    And since we update the current search hash, this useEffect is now triggered because clearSelectedTransactions depends on currentSearchHash.

    useEffect(() => {
    clearSelectedTransactions(hash);
    setCurrentSearchHash(hash);
    }, [hash, clearSelectedTransactions, setCurrentSearchHash]);

    To simplify this, we can move the useEffect logic into the useFocusEffect.

    useFocusEffect(useCallback(() => {
        clearSelectedTransactions(hash);
        setCurrentSearchHash(hash);
    }, [hash, clearSelectedTransactions, setCurrentSearchHash]));
    

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

    N/A

  4. nkdengineer commented on Jun 3, 2025

    @nkdengineer
    Contributor

    Proposal

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

    After deleting an expense on "Expenses" section and returning to "Chats" using the device´s back button, all the messages are displayed with fallback avatar.

    What is the root cause of that problem?

    There're 2 issues:

    1. Snapshot is not updated correctly

    We're getting the personalDetails from snapshot

    const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {

    and it's updated whenever we call Search API. For now we have 2 type of Search API: expense and chat.

    1. expense will be called here when users open Expenses or Reports pages
    2. chat will be called here when users open Chat pages

    But in this case, if users open Chat page by using browser back button, this logic is not triggered since it's still in the stack and isn't unmounted.

    So the snapshot is not updated as usual

    In conclusion, hash and snapshot are not updated when users back to Chat page

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

    1. Trigger Search API call with the correct type in here
    useEffect(() => {
            if (isOffline || !isFocused) {
                return;
            }
            handleSearch({queryJSON, offset});
        }, [handleSearch, isOffline, offset, queryJSON, isFocused]);
    
    1. Update hash in here
    useEffect(() => {
            if (!isFocused) {
                return;
            }
            clearSelectedTransactions(hash);
            setCurrentSearchHash(hash); 
        }, [hash, clearSelectedTransactions, setCurrentSearchHash, isFocused]);
    

    Note: If we just only update the hash, the Search API will be triggered again with the previous type (expense)

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

    None

    What alternative solutions did you explore? (Optional)

    N/A
    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  5. melvin-bot commented on Jun 6, 2025

    @melvin-bot

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

  6. melvin-bot commented on Jun 10, 2025

    @melvin-bot

    @zanyrenney 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

  7. melvin-bot commented on Jun 12, 2025

    @melvin-bot

    @zanyrenney 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

  8. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jun 12, 2025
  9. changed the title [-]Reports - After deleting expense and returning to "Chats" messages display fallback avatar.[/-] [+][$250] Reports - After deleting expense and returning to "Chats" messages display fallback avatar.[/+] on Jun 12, 2025
  10. zanyrenney commented on Jun 12, 2025

    @zanyrenney
    Contributor

    weird, why did this not assign a c+...

  11. 67 remaining items

  12. melvin-bot commented on Jul 7, 2025

    @melvin-bot

    @c3024 @zanyrenney The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  13. mallenexpensify commented on Jul 7, 2025

    @mallenexpensify
    Contributor

    Popping in here quick - In the proposal template we ask

    What is the root cause of that problem?
    What changes do you think we should make in order to solve the problem?

    We want to focus on the root cause and solution to fix that. It's possible that improvements are made as part of the initial PR or additional PRs but... we should stick with focusing on the solution specific to the root cause and follow this from CONTRIBUTING.md .

    Note: Before submitting a proposal on an issue, be sure to read any other existing proposals. ALL NEW PROPOSALS MUST BE DIFFERENT FROM EXISTING PROPOSALS. The difference should be important, meaningful or considerable.

    So.. for this, it looks/sounds like we should move forward with @bernhardoj 's proposal and PR. It also sounds like @nkdengineer 's proposed improvements are valuable so we should create an issue for that and assign both @c3024 and @nkdengineer there. @cristipaval , can you do that? (I haven't been following this issue and am unsure of the exact deliverable or steps).

  14. mallenexpensify commented on Jul 14, 2025

    @mallenexpensify
    Contributor

    Contributor: @bernhardoj due $250 via NewDot
    Contributor+: @c3024 due $250 via NewDot

    @c3024 plz complete the BZ checklist.

  15. melvin-bot commented on Jul 14, 2025

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1933156796042939339/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  16. bernhardoj commented on Jul 14, 2025

    @bernhardoj
    Contributor

    Requested in ND.

  17. JmillsExpensify commented on Jul 14, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @bernhardoj

  18. zanyrenney commented on Jul 15, 2025

    @zanyrenney
    Contributor

    @c3024 please complete the checklist?

  19. c3024 commented on Jul 15, 2025

    @c3024
    Contributor

    I'll complete it today. Thanks for the bump!

  20. c3024 commented on Jul 16, 2025

    @c3024
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
    • 2b. Reported on staging (eg. found during regression or PR testing)
    • 2d. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: https://github.com/Expensify/App/pull/46406/files#r2210526020

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: Not a critical regression to start a discussion.

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    Regression Test Proposal Template

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Precondition:

    • None

    Test:

    1. Create a new account
    2. Create a new workspace
    3. Open Reports
    4. Switch to Chat > Reports
    5. Press browser or device back button
    6. Verify the chat list items show the avatar correctly

    Do we agree 👍 or 👎

  21. zanyrenney commented on Jul 17, 2025

    @zanyrenney
    Contributor

    Payments

    Reviewer: @bernhardoj owed $250 via NewDot - PAID
    Reviewer: @c3024 owed $250 via NewDot - Please request on ND.

  22. twisterdotcom commented on Jul 28, 2025

    @twisterdotcom
    Contributor

    @c3024 has submitted payment for this report on ND here.

    SO: https://stackoverflowteams.com/c/expensify/questions/7582

    • Vendor found in VML: True. Status: Active
    • Amount requested: $250.00 (Matches the payment summary above.)
    • I, @twisterdotcom am not already the BZ assignee. I have approved this payment.
    Zapier Logs Run ID: 00040eee-4a60-a92d-a0b5-01713afa5d81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions