Open izarutskaya opened 4 months ago
Triggered auto assignment to @sonialiap (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.
Triggered auto assignment to @iwiznia (DeployBlockerCash
), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.
:wave: 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:
We think this issue might be related to the #collect project.
Job added to Upwork: https://www.upwork.com/jobs/~01c66dfe570a289fac
Triggered auto assignment to Contributor-plus team member for initial proposal review - @alitoshmatov (External
)
We pass isFromRHP
to true without checking the screen size (whether we are on larger screen or smaller):
https://github.com/Expensify/App/blob/fc9b7ac988a1e520fcdb904ae13dfd6e091f8bcd/src/pages/ReportDetailsPage.tsx#L778
This will trigger us to dismiss the modal first and then navigate back:
https://github.com/Expensify/App/blob/fc9b7ac988a1e520fcdb904ae13dfd6e091f8bcd/src/libs/ReportUtils.ts#L3594-L3600
Simplest fix would be to use the check the screen size from the hook useResponsiveLayout
and only pass true if we are on bigger screen
const {isSmallScreenWidth} = useResponsiveLayout();
ReportUtils.navigateBackAfterDeleteTransaction(navigateBackToAfterDelete.current, !isSmallScreenWidth ? true: false);
I assume there is a check for large screen too, both can be used either ways
I assume that is what was intended with the PR https://github.com/Expensify/App/pull/44537
does that make sense to you @iwiznia ?
Oh right, seems that PR did not fix the issue it was intended to fix, going to close in favor of that issue
⚠️ Looks like this issue was linked to a Deploy Blocker here
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.
If a regression has occurred and you are the assigned CM follow the instructions here.
If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.
Edited by proposal-police: This proposal was edited at 2024-08-06 13:59:34 UTC.
Not here page shows up briefly when deleting the expense.
After deleting the transaction, we delete the data first here, then navigate later https://github.com/Expensify/App/blob/371093660f398a3895726931baa303ce9d823e5d/src/pages/ReportDetailsPage.tsx#L778
So the data will be updated even before the user finishes the navigation back, this causes the brief deleted-transaction data (not found page/[Deleted expense]
text) to show in the screen (which is still navigating back).
We should navigate the user back first, then delete the transaction data in the background after the user has successfully navigated. This will make sure through out the navigation back, the user still sees the correct transaction data.
const { urlToNavigateBack } = IOU.prepareToCleanUpMoneyRequest(iouTransactionID, requestParentReportAction, true);
navigateBackToAfterDelete.current = urlToNavigateBack;
So at this step we just set the navigateBackToAfterDelete.current
and not deleting the data yet (we'll delete in a step later). This logic is the same as the values returned when calling IOU.deleteMoneyRequest
here so there'll be no problem
ReportUtils.navigateBackAfterDeleteTransaction(navigateBackToAfterDelete.current, true);
setTimeout(() => { IOU.deleteMoneyRequest(iouTransactionID, requestParentReportAction, isSingleTransactionView); }, CONST.ANIMATED_TRANSITION);
In summary, we only change the order in which optimistic data update and navigation back happens, we don't make any logic change. That's for submit expense case, we should check track expense case and handle in similar manner.
### What alternative solutions did you explore? (Optional)
We could additionally add the change suggested [above here](https://github.com/Expensify/App/issues/45576#issuecomment-2233093947), but this does not fully fix the issue, `[Deleted expense]` still shows and also buttons disappearing, before the user is navigated back. So it's an incremental thing we can add.
Alternative to `waitForNavigate` approach, we can use `setTimeout` with the navigation timeout (similar to in [here](https://github.com/Expensify/App/blob/963f8ce2c108d543c5058e7574f21465106440a6/src/hooks/useAutoFocusInput.ts#L41)). Or we can delete the data in `InteractionManager.runAfterInteractions`, but it might not work as reliably.
<!---
ATTN: Contributor+
You are the first line of defense in making sure every proposal has a clear and easily understood problem with a "root cause". Do not approve any proposals that lack a satisfying explanation to the first two prompts. It is CRITICALLY important that we understand the root cause at a minimum even if the solution doesn't directly address it. When we avoid this step we can end up solving the wrong problems entirely or just writing hacks and workarounds.
Instructions for how to review a proposal:
1. Address each contributor proposal one at a time and address each part of the question one at a time e.g. if a solution looks acceptable, but the stated problem is not clear then you should provide feedback and make suggestions to improve each prompt before moving on to the next. Avoid responding to all sections of a proposal at once. Move from one question to the next each time asking the contributor to "Please update your original proposal and tag me again when it's ready for review".
2. Limit excessive conversation and moderate issues to keep them on track. If someone is doing any of the following things please kindly and humbly course-correct them:
- Posting PRs.
- Posting large multi-line diffs (this is basically a PR).
- Skipping any of the required questions.
- Not using the proposal template at all.
- Suggesting that an existing issue is related to the current issue before a problem or root cause has been established.
- Excessively wordy explanations.
3. Choose the first proposal that has a reasonable answer to all the required questions.
-->
Hey @iwiznia the other issue was closed and this is still reproducible. As explained in my proposal this has a different RCA and won't be fixed in that issue.
Could you help reopen this GH issue to address the bug?
Kind thanks!
Proposal updated with small alternative approach
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
@iwiznia, @sonialiap, @alitoshmatov Whoops! This issue is 2 days overdue. Let's get this updated quick!
@alitoshmatov can you review the proposal and keep this moving please? Thanks!
We need IOU.deleteMoneyRequest
to be executed so it returns a url to navigate back. How are planning on not calling this function but still getting url to navigate back?
hey @alitoshmatov , can you also check my proposed solution here, thanks
@allgandalf Sorry missed your proposal.
Your solution seems to be working but now, instead of not found page, title is changing into [deleted expense]
https://github.com/user-attachments/assets/53a2fef7-fb71-4685-b0ae-f0af7ea55a9c
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
That is because we wait for the action to get completed, but if we want it to happen in the background then we can do it without waiting for the interaction to be completed:
@allgandalf Sorry missed your proposal.
Actually i am sorry @alitoshmatov , for not posting a proper proposal format, it happened that i came in from slack to test this bug and posted a simple fix for it. do let me know if you need any other details
@iwiznia, @sonialiap, @alitoshmatov Whoops! This issue is 2 days overdue. Let's get this updated quick!
@iwiznia @sonialiap @alitoshmatov this issue is now 4 weeks old, please consider:
Thanks!
We need IOU.deleteMoneyRequest to be executed so it returns a url to navigate back. How are planning on not calling this function but still getting url to navigate back?
Updating on this shortly...
We need IOU.deleteMoneyRequest to be executed so it returns a url to navigate back. How are planning on not calling this function but still getting url to navigate back?
urlToNavigateBack
is just a value that's returned from prepareToCleanUpMoneyRequest
(reference), so we can call prepareToCleanUpMoneyRequest
directly to get it, no need to call IOU.deleteMoneyRequest
.
const { urlToNavigateBack } = IOU.prepareToCleanUpMoneyRequest(iouTransactionID, requestParentReportAction, true);
(prepareToCleanUpMoneyRequest
needs to be exported from IOU
)
Alternatively, we can extract only the parts that produce the urlToNavigateBack
inside prepareToCleanUpMoneyRequest
into a new method getUrlToNavigateBackAfterMoneyRequestCleanUp
@iwiznia, @sonialiap, @alitoshmatov Huh... This is 4 days overdue. Who can take care of this?
Triggered auto assignment to @RachCHopkins (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.
@RachCHopkins I'm OOO Aug 19-30, adding leave buddy. Status: waiting for proposals / C+ to review proposals
That is because we wait for the action to get completed, but if we want it to happen in the background then we can do it without waiting for the interaction to be completed:
@allgandalf That does still not work
@daledah Can you provide detailed changes for your solution, I am still struggling to understand it.
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
No Melvin, still evaluating proposals
@iwiznia, @sonialiap, @RachCHopkins, @alitoshmatov Whoops! This issue is 2 days overdue. Let's get this updated quick!
@alitoshmatov Proposal updated to highlight detailed code changes
Issue not reproducible during KI retests. (First week)
@iwiznia, @sonialiap, @RachCHopkins, @alitoshmatov Huh... This is 4 days overdue. Who can take care of this?
Edited by proposal-police: This proposal was edited at 2024-10-07 09:47:20 UTC.
ReportDetailsPage
and deleting the expense.These issues are noticeable on mobile devices due to their slower performance compared to web/desktop, but they occur across all platforms and layout sizes.
We should decouple target URL generation when deleting a transaction, navigate to target url on confirm delete and perform actual deletion after ReportDetailsPage
unmounted.
Extract url generation to these components getNavigationUrlAfterTaskDelete
, getNavigationUrlAfterMoneyRequestDelete
, getNavigationUrlAfterTrackExpenseDelete
.
Move onHideModalLogic
to a new function navigateToTargetUrl
that will only navigate without actual deletion
The deleteTransaction
will only responsible for actual deletion without URL generation and will be called in unmount phase of ReportDetailsPage
if isTransactionDeleted.current
true.
useEffect(() => {
return () => {
if (!isTransactionDeleted.current) {
return;
}
deleteTransaction();
};
}, []);
In mWeb, even when we navigate to destination report earlier, not found might still appear, to handle this we can re-implement soft deletion of thread report from my previous proposal (see. alternative proposal),
Optional
After we implement the solution, the update of target report might be delayed. This is expected because we reach the target report too early
https://github.com/user-attachments/assets/d68329c9-cd9b-4a66-977a-93c69382ebfa
[!NOTE]
Auto scroll issue is known separate issue https://github.com/Expensify/App/issues/45576#issuecomment-2384466032
If we don't want to show the delay, we can store target url in NVP_DELETE_TRANSACTION_NAVIGATE_BACK_URL
to determine if we should show skeleton or not.
In Task.deleteTask, IOU.deleteTrackExpense, IOU.deleteMoneyRequest reset NVP_DELETE_TRANSACTION_NAVIGATE_BACK_URL
when optimisticData updated
optimisticData.push({
onyxMethod: Onyx.METHOD.SET,
key: ONYXKEYS.NVP_DELETE_TRANSACTION_NAVIGATE_BACK_URL,
value: null,
});
Add new useEffect to clear the url and modify shouldShowSkeleton
logic in ReportScreen
const [deleteTransactionNavigateBackUrl] = useOnyx(ONYXKEYS.NVP_DELETE_TRANSACTION_NAVIGATE_BACK_URL);
useEffect(() => {
if (!isFocused || !deleteTransactionNavigateBackUrl) {
return;
}
// Schedule the code to run after the current call stack is cleared,
// ensuring all updates are processed before hide the skeleton
lodashDefer(() => {
Onyx.merge(ONYXKEYS.NVP_DELETE_TRANSACTION_NAVIGATE_BACK_URL, null);
});
}, [isFocused]);
const isLoading = isLoadingApp ?? ((!reportIDFromRoute || (!isSidebarLoaded && !isInNarrowPaneModal) || PersonalDetailsUtils.isPersonalDetailsEmpty()));
const shouldShowSkeleton =
(isLinkingToMessage && !isLinkedMessagePageReady) ||
(!isLinkingToMessage && !isInitialPageReady) ||
isEmptyObject(reportOnyx) ||
isLoadingReportOnyx ||
!isCurrentReportLoadedFromOnyx ||
(deleteTransactionNavigateBackUrl && ReportUtils.getReportIDFromLink(deleteTransactionNavigateBackUrl) === report?.reportID) ||
isLoading;
Further, we can make Task.deleteTask, IOU.deleteTrackExpense, IOU.deleteMoneyRequest completely not return URL or use our new decoupled functions to prevent duplicate code.
[!NOTE]
This solution not solve all cases
Change transaction thread optimistic data
To
if (shouldDeleteTransactionThread) {
optimisticData.push(
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadID}`,
value: {
reportID: null,
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
statusNum: CONST.REPORT.STATUS_NUM.CLOSED,
notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
},
},
When success, remove remaining properties value to ensure the object completely deleted:
if(shouldDeleteTransactionThread) {
successData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadID}`,
value: Object.keys(transactionThread as OnyxTypes.Report).reduce<Record<string, null>>((acc, key) => {
acc[key] = null;
return acc;
}, {}),
})
}
Do the same for getDeleteTrackExpenseInformation
isDeletedButtonPressed
to know that the deletion process confirmed.Change
To:
onConfirm={()=>{
Navigation.dismissModal();
setIsDeleteModalVisible(false);
isDeletedButtonPressed.current = true;
}}
And modify onModalHide
to:
onModalHide={() => {
if (isDeletedButtonPressed.current) {
deleteTransaction();
}
// We use isTransactionDeleted to know if the modal hides because the user deletes the transaction.
if (!isTransactionDeleted.current) {
if (caseID === CASES.DEFAULT) {
if (navigateBackToAfterDelete.current) {
......
Remove setIsDeleteModalVisible(false);
in deleteTransaction
@wildan-m Thank you for your proposal, I really liked the first solution, but does not solve the complete problem. The second solution I think is similar to @daledah 's proposal in some way.
I think we can go with @daledah 's proposal which suggests delaying deletion until page animation is complete
C+ reviewed 🎀 👀 🎀
Triggered auto assignment to @luacmartins, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
@alitoshmatov Thanks for your review. I wanted to clarify that I only proposed one solution for each issue. They should be implemented together since the root causes are different. My delay for the second issue is based on the hide modal event, not on a timeout. I believe this should be considered distinct.
Proposal LGTM and we already call the same navigateBackAfterDeleteTransaction
in a few other places.
📣 @alitoshmatov 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!
📣 @daledah You have been assigned to this job! Please apply to the Upwork job and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑💻 Once you apply to this job, your Upwork ID will be stored and you will be automatically hired for future jobs! Keep in mind: Code of Conduct | Contributing 📖
@alitoshmatov how is this going?
@RachCHopkins thanks for buddy sitting this! Taking it back off of your plate 🍽️
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.8-1 Reproducible in staging?: Y Reproducible in production?: N Found when executing PR : https://github.com/Expensify/App/pull/44537 Logs: https://stackoverflow.com/c/expensify/questions/4856 Issue reported by: Applause-Internal team
Action Performed:
Expected Result:
Not here page will not show up when deleting the expense.
Actual Result:
Not here page shows up briefly when deleting the expense.
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
https://github.com/user-attachments/assets/819b601e-65bc-4aab-82ea-69cfa7faa418
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @alitoshmatov