Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Due for payment 2025-02-25] Per diem - RHP shows offline view when deleted, fields are not grayed out when edited offline #54488

Closed
5 of 8 tasks
lanitochka17 opened this issue Dec 24, 2024 · 29 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Engineering Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Dec 24, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.0.78-0
Reproducible in staging?: Y
Reproducible in production?: N
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
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): [email protected]
Issue reported by: Applause - Internal Team

Action Performed:

  • Workspace has Per diem rates
  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Per diem
  3. Go offline
  4. Click on any rate
  5. Click Delete
  6. Delete the rate
  7. Do any edit offline for other rate

Expected Result:

In Step 6, after deleting the rate, RHP will not show offline view

Actual Result:

In Step 6, after deleting the rate, RHP shows offline view while dismissing

Workaround:

Unknown

Platforms:

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

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
Bug6701539_1734998541203.20241224_075747.mp4
Bug6701539_1734998541197!Screenshot_2024-12-24_at_08 00 06

Bug6701539_1734998541202!German_Per_Diem_-Dependent_Tags___2.csv

View all open jobs on GitHub

@lanitochka17 lanitochka17 added the DeployBlockerCash This issue or pull request should block deployment label Dec 24, 2024
Copy link

melvin-bot bot commented Dec 24, 2024

Triggered auto assignment to @marcaaron (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

Copy link

melvin-bot bot commented Dec 24, 2024

💬 A slack conversation has been started in #expensify-open-source

Copy link
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.

@daledah
Copy link
Contributor

daledah commented Dec 24, 2024

Edited by proposal-police: This proposal was edited at 2024-12-24 04:46:36 UTC.

Proposal

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

In Step 6, after deleting the rate, RHP shows offline view while dismissing
In Step 7, when editing any rate, the rate and the edited fields are not grayed out

What is the root cause of that problem?

This new feature comes from: #53625

  1. In Step 6, after deleting the rate, RHP shows offline view while dismissing

The navigation take time to dismiss modal, and after deleting the subRate we're removing it in optimistic data

customUnitOnyxUpdate.rates[rateID] = null;
} else {
const newSubRates = newCustomUnit.rates[rateID].subRates?.filter((subRate) => !subRates.some((subRateToBeDeleted) => subRateToBeDeleted.subRateID === subRate.id));
newCustomUnit.rates[rateID].subRates = newSubRates;
customUnitOnyxUpdate.rates[rateID] = {...customUnitOnyxUpdate.rates[rateID], subRates: newSubRates};

that causes selectedSubRate is undefined so offline view is shown

https://github.com/Expensify/App/blob/8b7096fc4c4d522407a6f51b4fe0fd3543e5feb2/src/pages/workspace/perDiem/WorkspacePerDiemDetailsPage.tsx#L46C48-L46C63

  1. In Step 7, when editing any rate, the rate and the edited fields should be grayed out

We didn't update pendingAction and pendingFields in edit action

customUnits: {
[customUnit.customUnitID]: newCustomUnit,
},

...

and didn't wrap OfflineWithFeedback for MenuItem

so we don't see the gray out option

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

  1. Don't remove subRate in optimistic data when delete

Here is the sample code

const newSubRatesOnyx = newCustomUnit.rates[rateID].subRates?.map((subRate) => {
            const shouldDelete = subRates.some((subRateToBeDeleted) => subRateToBeDeleted.subRateID === subRate.id);
            return {
                ...subRate,
                pendingAction: shouldDelete ? CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE : subRate.pendingAction,
            }
        });
        if (subRates.length === newCustomUnit.rates[rateID].subRates?.length) {
            delete newCustomUnit.rates[rateID];
        } else {
            const newSubRates = newCustomUnit.rates[rateID].subRates?.filter((subRate) => !subRates.some((subRateToBeDeleted) => subRateToBeDeleted.subRateID === subRate.id));
            
            newCustomUnit.rates[rateID].subRates = newSubRates;
        }
        if(customUnitOnyxUpdate.rates[rateID]?.subRates){
            customUnitOnyxUpdate.rates[rateID].subRates = newSubRatesOnyx
        }
  1. When update perdiem data, we should update pendingFields and pendingAction in editPerDiemRateDestination and other funcs

then wrap every menu item inside OfflineWithFeedback

For example:

<OfflineWithFeedback pendingAction={selectedSubRate?.pendingFields?.['name']}>
                        <MenuItemWithTopDescription
                            title={selectedRate?.name}
                            description={translate('workspace.perDiem.destination')}
                            onPress={() => Navigation.navigate(ROUTES.WORKSPACE_PER_DIEM_EDIT_DESTINATION.getRoute(policyID, rateID, subRateID))}
                            shouldShowRightIcon
                        />
                        </OfflineWithFeedback>
  1. Update getSubRatesData

pendingAction: rate.pendingAction,

to

pendingAction: subRate.pendingAction,

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

What alternative solutions did you explore? (Optional)

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.

Result

Screen.Recording.2024-12-24.at.11.41.42.mov

@daledah
Copy link
Contributor

daledah commented Dec 24, 2024

@marcaaron What do you think about my proposal. I can create the quick PR for this DB

@parasharrajat
Copy link
Member

parasharrajat commented Dec 24, 2024

Proposal looks good to me. But does this needs to be implemented as part of original PR #53625 given that we are still in regression period.

@daledah
Copy link
Contributor

daledah commented Dec 25, 2024

@parasharrajat It's the new feature and I think it's hard to cover all cases. By the way, offline mode is quite complex to implement so it can be handle in the separate PR. cc @marcaaron

@parasharrajat
Copy link
Member

parasharrajat commented Dec 25, 2024

Not sure about that. Let's wait for Marc's reply. There are a few issues poping up from per diem implementation. May be there are pending things from the design doc.

@shubham1206agra
Copy link
Contributor

Step 7 is intentional since we are using Pattern A here.

@melvin-bot melvin-bot bot added the Overdue label Dec 26, 2024
@jasperhuangg
Copy link
Contributor

Yeah, lets please implement this as part of the original PR, it's definitely a regression that should be fixed. @parasharrajat @daledah

@jasperhuangg
Copy link
Contributor

I'm going to remove the blocker label since this is pretty edge-casey, and it seems we need to sort out which pattern is intended here.

@jasperhuangg jasperhuangg added Daily KSv2 and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 labels Dec 26, 2024
@melvin-bot melvin-bot bot removed the Overdue label Dec 26, 2024
@parasharrajat
Copy link
Member

parasharrajat commented Dec 26, 2024

In that case, I am going to tag the original Author/C+.

@shubham1206agra Can you please look into this as it is a regression from your PR?

@shubham1206agra
Copy link
Contributor

lets please implement this as part of the original PR

@jasperhuangg I think the only bug is in step 6. Step 7 is intentional. Please update the issue to reflect that.

@melvin-bot melvin-bot bot added the Overdue label Dec 30, 2024
Copy link

melvin-bot bot commented Dec 30, 2024

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

Copy link

melvin-bot bot commented Jan 1, 2025

@marcaaron Huh... This is 4 days overdue. Who can take care of this?

Copy link

melvin-bot bot commented Jan 3, 2025

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

@parasharrajat
Copy link
Member

@shubham1206agra Have you created the fix yet?

@shubham1206agra
Copy link
Contributor

Not yet, but planning to do so today itself.

Copy link

melvin-bot bot commented Jan 7, 2025

@marcaaron 10 days overdue. I'm getting more depressed than Marvin.

@daledah
Copy link
Contributor

daledah commented Jan 7, 2025

@marcaaron I can help to create the PR fix to speed it up cc @parasharrajat

@parasharrajat
Copy link
Member

And I can review asap.

@shubham1206agra
Copy link
Contributor

@daledah Thanks for the help, but I don't think your proposal is correct.

@huult
Copy link
Contributor

huult commented Jan 9, 2025

Proposal

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

RHP shows offline view when deleted, fields are not grayed out when edited offline

What is the root cause of that problem?

When deleting a Per Diem rate in offline mode, the deleted rate is removed from Onyx, causing selectedSubRate to become undefined.

const selectedSubRate = selectedRate?.subRates?.find((subRate) => subRate.id === subRateID);

So we will briefly show the offline page before closing the modal

https://github.com/Expensify/App/blob/0ee0a123dac5b49f00da6c90619c03d5dabdd71f/src/pages/workspace/perDiem/WorkspacePerDiemDetailsPage.tsx#L46C48-L46C63

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

To resolve this issue, we should update the condition for displaying the offline page to ensure that it is not displayed unnecessarily after navigating back

https://github.com/Expensify/App/blob/0ee0a123dac5b49f00da6c90619c03d5dabdd71f/src/pages/workspace/perDiem/WorkspacePerDiemDetailsPage.tsx#L46C48-L46C63

Update to

    const [hasNavigatedBack, setHasNavigatedBack] = useState(false);
    let FullPageBlockingView;

    if (hasNavigatedBack) {
        FullPageBlockingView = View;
    } else if (isEmptyObject(selectedSubRate)) {
        FullPageBlockingView = FullPageOfflineBlockingView;
    } else {
        FullPageBlockingView = View;
    }

const handleDeletePerDiemRate = () => {

Update to

    const handleDeletePerDiemRate = () => {
        ...
        setHasNavigatedBack(true);
        ...
    };

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

This is a UI bug and does not require a unit test

What alternative solutions did you explore? (Optional)

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.

Copy link

melvin-bot bot commented Jan 9, 2025

@marcaaron 12 days overdue now... This issue's end is nigh!

@melvin-bot melvin-bot bot removed the Daily KSv2 label Jan 13, 2025
Copy link

melvin-bot bot commented Jan 13, 2025

This issue has not been updated in over 14 days. @marcaaron eroding to Weekly issue.

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Overdue labels Jan 13, 2025
@melvin-bot melvin-bot bot added the Overdue label Jan 21, 2025
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Weekly KSv2 Overdue labels Feb 3, 2025
@Gonals Gonals assigned Gonals and marcaaron and unassigned marcaaron Feb 13, 2025
@Gonals
Copy link
Contributor

Gonals commented Feb 13, 2025

This'll be fixed by @shubham1206agra as part of the per diem project

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Feb 18, 2025
@melvin-bot melvin-bot bot changed the title Per diem - RHP shows offline view when deleted, fields are not grayed out when edited offline [Due for payment 2025-02-25] Per diem - RHP shows offline view when deleted, fields are not grayed out when edited offline Feb 18, 2025
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Feb 18, 2025
Copy link

melvin-bot bot commented Feb 18, 2025

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Feb 18, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.99-2 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2025-02-25. 🎊

@shubham1206agra
Copy link
Contributor

@Gonals No payment required here. Please close this issue.

@Gonals Gonals closed this as completed Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Engineering Weekly KSv2
Projects
None yet
Development

No branches or pull requests

8 participants