Skip to content

[$500] [HOLD for payment 2023-10-02] [HOLD for payment 2023-09-29] RM - App crashed when tap replace receipt #27903

Closed

Description

@lanitochka17

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Issue found when executing PR #26508

  1. Launch App
  2. Request money via Scan option
  3. Tap the report preview
  4. Tap the request preview
  5. Tap the receipt image
  6. When the modal opens, tap the three dot menu at the top
  7. Select replace

Action Performed:

Camera should be open again to replace the receipt image.

Expected Result:

App crashed when tap replace receipt
Issue occurred on Android App as well

Workaround:

Unknown

Platforms:

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

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.72-6

Reproducible in staging?: Yes

Reproducible in production?: No

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

Notes/Photos/Videos: Any additional supporting documentation

Bug6208089_receipt_crash.mp4

Expensify/Expensify Issue URL:

Issue reported by: Applause - Internal Team

Slack conversation:

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~016d18ed8dd8d228a2
  • Upwork Job ID: 1709869686165725184
  • Last Price Increase: 2023-10-05

Activity

  1. added
    DeployBlockerCash
    Daily
    Bug
    on Sep 20, 2023
  2. melvin-bot commented on Sep 20, 2023

    @melvin-bot

    Triggered auto assignment to @laurenreidexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

  3. melvin-bot commented on Sep 20, 2023

    @melvin-bot

    Bug0 Triage Checklist (Main S/O)

    • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
    • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
      • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
    • This bug is reproducible using the reproduction steps in the OP. S/O
      • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
      • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
    • This issue is filled out as thoroughly and clearly as possible
      • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
    • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync
  4. OSBotify commented on Sep 20, 2023

    @OSBotify
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open StagingDeployCash deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  5. melvin-bot commented on Sep 20, 2023

    @melvin-bot

    Auto-assign attempt failed, all eligible assignees are OOO.

  6. akinwale commented on Sep 21, 2023

    @akinwale
    Contributor

    Proposal

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

    The app crashes when attempting to replace a receipt.

    What is the root cause of that problem?

    When the Replace Receipt option is selected, the app navigates to the EditRequestReceiptPage component which contains a ReceiptSelector. On native platforms, ReceiptSelector makes use of a NavigationAwareCamera which uses the useTabAnimation() hook.

    const tabPositionAnimation = useTabAnimation();

    This hook is designed to throw an error if the component using it is not embedded within a tab. Since the ReceiptSelector in this scenario is not within a tab, the app crashes with this error.

    +export function useTabAnimation() {
    + const animation = React.useContext(TabAnimationContext);
    + if (animation === undefined) {
    + throw new Error("Couldn't find values for card animation. Are you inside a screen in Tab?");
    + }
    + return animation;
    +}

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

    Add a way to check if the component is within a tab and then update the implementation accordingly. This can be achieved with the following steps in either solution.

    Solution 1

    1. Update the default value of the lodashGet call for the pageIndex param in ReceiptSelector.
    -const pageIndex = lodashGet(route, 'params.pageIndex', 1);
    +const pageIndex = lodashGet(route, 'params.pageIndex', -1);
    1. Conditionally set tabPositionAnimation based on the value of cameraTabIndex (which is set to the value of pageIndex).
    +const tabPositionAnimation = cameraTabIndex > -1 ? useTabAnimation() : null;
    useEffect(() => {
    +    if (!tabPositionAnimation) {
    +        return;
    +    }
        const listenerId = tabPositionAnimation.addListener(({value}) => {
            // Activate camera as soon the index is animating towards the `cameraTabIndex`
            setIsCameraActive(value > cameraTabIndex - 1 && value < cameraTabIndex + 1);
        });
    
        return () => {
            tabPositionAnimation.removeListener(listenerId);
        };
    }, [cameraTabIndex, tabPositionAnimation]);

    Solution 2

    1. Add a lodashGet for a new param in ReceiptSelector, isTab which should indicate whether or not the component is in a tab.
    const isTab = lodashGet(route, 'params.isTab', 0);
    
    1. Pass the isTab param as a prop to the NavigationAwareCamera component.
    <NavigationAwareCamera
      ref={camera}
      ...
    +  isTab={isTab}
    />
    1. Update the initialParams for the ReceiptSelector tab in MoneyRequestSelectorPage.
    <TopTab.Screen
        name={CONST.TAB.SCAN}
        component={ReceiptSelector}
    -    initialParams={{reportID, iouType, pageIndex: 1}}
    +    initialParams={{reportID, iouType, pageIndex: 1, isTab: 1}}
    />
    1. Add support for the isTab prop to the NavigationAwareCamera component.
    function NavigationAwareCamera({cameraTabIndex, isTab, forwardedRef, ...props}) {
    
    1. Conditionally set tabPositionAnimation based on the value of isTab.
    +const tabPositionAnimation = isTab ? useTabAnimation() : null;
    useEffect(() => {
    +    if (!tabPositionAnimation) {
    +        return;
    +    }
        const listenerId = tabPositionAnimation.addListener(({value}) => {
            // Activate camera as soon the index is animating towards the `cameraTabIndex`
            setIsCameraActive(value > cameraTabIndex - 1 && value < cameraTabIndex + 1);
        });
    
        return () => {
            tabPositionAnimation.removeListener(listenerId);
        };
    }, [cameraTabIndex, tabPositionAnimation]);

    What alternative solutions did you explore? (Optional)

    None.

  7. 34 remaining items

  8. added
    External
    on Oct 5, 2023
  9. changed the title [-][HOLD for payment 2023-10-02] [HOLD for payment 2023-09-29] RM - App crashed when tap replace receipt[/-] [+][$500] [HOLD for payment 2023-10-02] [HOLD for payment 2023-09-29] RM - App crashed when tap replace receipt[/+] on Oct 5, 2023
  10. melvin-bot commented on Oct 5, 2023

    @melvin-bot
  11. added
    Help Wanted
    on Oct 5, 2023
  12. melvin-bot commented on Oct 5, 2023

    @melvin-bot

    Current assignees @akinwale and @parasharrajat are eligible for the External assigner, not assigning anyone new.

  13. removed
    Help Wanted
    on Oct 5, 2023
  14. laurenreidexpensify commented on Oct 5, 2023

    @laurenreidexpensify
    Contributor

    @akinwale apols, Upwork job live now! Please apply and I will adjust payment to $125 when when we pay out the job. Thanks!

  15. akinwale commented on Oct 5, 2023

    @akinwale
    Contributor

    @akinwale apols, Upwork job live now! Please apply and I will adjust payment to $125 when when we pay out the job. Thanks!

    @laurenreidexpensify Applied. Thanks!

  16. parasharrajat commented on Oct 5, 2023

    @parasharrajat
    Member

    Note: I don't think we used any of the existing proposals. Initially, we thought of using existing proposals then it as changed after my suggestion #27974 (comment). Thus the final solution does not use any proposals.

    @laurenreidexpensify

  17. parasharrajat commented on Oct 5, 2023

    @parasharrajat
    Member

    Payment requested as per #27903 (comment)

  18. JmillsExpensify commented on Oct 5, 2023

    @JmillsExpensify
    Contributor

    $500 payment approved for @parasharrajat based on BZ summary.

  19. laurenreidexpensify commented on Oct 9, 2023

    @laurenreidexpensify
    Contributor

    Thanks for confirmation @parasharrajat

    in that case @akinwale as we didn't use your proposals in end, there won't be a discretionary bonus after all. thanks all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentBugDailyEngineeringExternal

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions