Open lanitochka17 opened 2 weeks ago
Triggered auto assignment to @garrettmknight (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.
@garrettmknight 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
We clear the approval workflow data before closing the modal.
We should first call Navigation.goBack(); and only clear the data once the transition is complete.
Navigation.goBack(); // We also can use dismissModal and Modal.close
if (isInitialCreationFlow) {
InteractionManager.runAfterInteractions(() => {
Workflow.clearApprovalWorkflow();
});
}
Job added to Upwork: https://www.upwork.com/jobs/~021841560364430821283
Triggered auto assignment to Contributor-plus team member for initial proposal review - @s77rt (External
)
In Android, tapping add approval workflow " No members to display " shown briefly but in mweb while tapping back button No members to display " page is shown
InteractionManager.runAfterInteractions
or use Modal.close
const goBack = useCallback(() => {
Navigation.goBack();
InteractionManager.runAfterInteractions(() => {
if (!isInitialCreationFlow) {
return;
}
Workflow.clearApprovalWorkflow();
});
}, [isInitialCreationFlow]);
To do that we can use set
method here which is faster because I see that we always pass full approval workflow data to this function.
Or we can return the Onyx.merge
promise in this function then move the navigate logic to .then
of the promise returned by setApprovalWorkflow
function.
Edited by proposal-police: This proposal was edited at 2024-10-02 20:22:02 UTC.
Workflow - When tapping "Add Approval Workflow" or navigating back, the message "No members to display" is briefly shown.
When tapping the back button, the approval workflow object is set to null
:
https://github.com/Expensify/App/blob/f325244648646bff8fcba62e60979a530f14d2d3/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx#L149-L156
https://github.com/Expensify/App/blob/9d252e8b37c441d62d6b299421870d28fe2ed398/src/libs/actions/Workflow.ts#L340-L342 This causes the shouldShowListEmptyContent
variable to resolve to undefined
, not false
:
https://github.com/Expensify/App/blob/9d252e8b37c441d62d6b299421870d28fe2ed398/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx#L63 Since we display the listEmptyContent
if shouldShowListEmptyContent
is true
, the issue arises when shouldShowListEmptyContent
is undefined
. In such cases, the BaseSelectionList
component uses a default value of true
for shouldShowListEmptyContent
:
https://github.com/Expensify/App/blob/0993f367649a5c978cc870347dbc93eaf5bd8736/src/components/SelectionList/BaseSelectionList.tsx#L103 When an undefined
value is passed, the component interprets it as not provided, and defaults to true
.
We should ensure that the value passed is always a boolean, not undefined
.To do this, we can update the code here:
https://github.com/Expensify/App/blob/9d252e8b37c441d62d6b299421870d28fe2ed398/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx#L63 as follows:
const shouldShowListEmptyContent = !!(approvalWorkflow && approvalWorkflow.availableMembers.length === 0);
This ensures the empty page is only displayed when appropriate. we can do the same change in other arias that uses the shouldShowListEmptyContent
prop in the selectionlist
now, we will have an issue where the members list becomes empty before navigating back. To address this, and the problem where the sections list becomes empty after clearing the members list, we can introduce a ref
or state, isNavigatingBack
. This state will be set to true
if the user is navigating back after clearing the workflow.We will also use a usePrevious
ref for approvalWorkflow?.availableMembers
, which will be utilized in the section memo when the app is navigating back.
By implementing this solution, we maintain the synchronous behavior of first clearing the data and then performing the back action.
const [isNavigatingBack, setIsNavigatingBack] = useState(false);
const previousAvailableMembers = usePrevious(approvalWorkflow?.availableMembers);
setIsNavigatingBack(true)
in the goBack function before clearing the flowif (!approvalWorkflow?.members || isNavigatingBack) {
previousAvailableMembers
when navigating back instead of this :
if (approvalWorkflow?.availableMembers ?? isNavigatingBack) {
const workflowAvailableMembers = (isNavigatingBack ? previousAvailableMembers : approvalWorkflow?.availableMembers) ?? [];
const availableMembers = workflowAvailableMembers
|| isNavigatingBack
in this line .Tapping add approval workflow or tapping back shows diff. behavior in mweb&android
First, we only clear the workflow when the user presses Go Back. The workflow will not be cleared if the user clicks on the central pane to navigate the workflow page. The second issue is that we encounter the member's empty state because of this. https://github.com/Expensify/App/blob/19a137d26fee56f913eaec7c9b896915ddb002a9/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx#L149-L154
We should remove this implementation from here. In this component WorkspaceWorkflowsApprovalsExpensesFromPage
, we will only go back
https://github.com/Expensify/App/blob/19a137d26fee56f913eaec7c9b896915ddb002a9/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx#L149-L154
onBackButtonPress={()=>Navigation.goBack()}
And then in WorkspaceWorkflowsPage
We will clearApprovalWorkflow
before starting a new one here
Workflow.clearApprovalWorkflow();
Workflow.setApprovalWorkflow({
...INITIAL_APPROVAL_WORKFLOW,
availableMembers,
usedApproverEmails,
});
We can implement the same solution in other places too where we have this issue
In the alternative solution, we should also remove the clearApprovalWorkflow
from WorkspaceWorkflowsApprovalsExpensesFromPage
and use only goBack()
and in here we can use set
by doing this we'll make sure that every time we are setting value instead of merging
https://github.com/Expensify/App/blob/19a137d26fee56f913eaec7c9b896915ddb002a9/src/libs/actions/Workflow.ts#L336-L338
An empty state view is shown when opening/closing the approval workflow page.
When we open the page, we will set the approval data first and then navigate to the page. https://github.com/Expensify/App/blob/e61ee7fbe60acc12879b9d5cc6ef92c4a0b98caa/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx#L103-L108
However, the onyx data is not immediately available which is noticeable in slower devices like Android.
And when we close the page, we clear the approval data. https://github.com/Expensify/App/blob/e61ee7fbe60acc12879b9d5cc6ef92c4a0b98caa/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsExpensesFromPage.tsx#L149-L154
For the first problem, we can use Navigation.setNavigationActionToMicrotaskQueue
to delay the navigation.
https://github.com/Expensify/App/blob/e61ee7fbe60acc12879b9d5cc6ef92c4a0b98caa/src/libs/Navigation/setNavigationActionToMicrotaskQueue.ts#L1-L5
Navigation.setNavigationActionToMicrotaskQueue(() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS_APPROVALS_EXPENSES_FROM.getRoute(route.params.policyID)));
For the second problem, we can delay the clearing of data using InteractionManager, just like we did here. https://github.com/Expensify/App/blob/e61ee7fbe60acc12879b9d5cc6ef92c4a0b98caa/src/pages/workspace/workflows/approvals/WorkspaceWorkflowsApprovalsEditPage.tsx#L63-L67
@cretadn22, @nkdengineer, @Nodebrute and @bernhardoj Thank you for the proposals. The RCA makes sense in general but the not found view should only be shown if the approvalWorkflow
data is available and we have no members.
@abzokhattab Thanks for the proposal. The RCA makes sense. I find your solution the easiest to implement even though it will cause blank space to appear on animation instead of the not found view but I don't think thats something that we should optimize for. Overall looks good to me.
~🎀 👀 🎀 C+ reviewed~ (see https://github.com/Expensify/App/issues/50094#issuecomment-2392032487) Link to proposal
Triggered auto assignment to @stitesExpensify, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
@abzokhattab Actually I found that the solution is not enough. We get a weird view after selecting some users and going back
https://github.com/user-attachments/assets/f1e724ae-33bc-49e1-b035-d724a9d58692
@s77rt The selected proposal is not enough because we still need to fix the approval workflow will be cleared briefly before we go back to the workflow page.
Thanks @s77rt for the review, i extended my proposal to cover the other problem where the members list becomes empty when going back
to solve it i used a help state isNavigatingBack
that would allow to freeze the members list while clearing the flow.
the important this in my proposal is that it keeps the synchronous nature of clearing the data first then going back, not the other way around.
POC
https://github.com/user-attachments/assets/8ebe778e-5c5e-483c-949e-66e4dfc7c366
Since we need another "complementary" solution, I'm giving this another review:
InteractionManager.runAfterInteractions
setNavigationActionToMicrotaskQueue
and InteractionManager.runAfterInteractions
add delays and should be avoided@abzokhattab The new changes making this more complex and it feels like band-aid solution
I see, thanks for the review!
To do that we can use set method here which is faster because I see that we always pass full approval workflow data to this function.
@s77rt For the selected proposal, with the main or alternative we also need to use set
method in setApprovalWorkflow
function which is the key to fixing the Android native bug and I'm the first one who suggested this. For the mweb bug, I think moving clearApprovalWorkflow
or delaying the call of this function is fine because we don't call any API.
@nkdengineer I believe the key in @Nodebrute's proposal is to not call Workflow.clearApprovalWorkflow
on going back. Using Onyx.set
is not mandatory.
@s77rt Using Onyx.set
in setApprovalWorkflow
is mandatory to fix the Android native bug.
@nkdengineer Using a set
is part of my alternate proposal and differs from your proposal.
@nkdengineer
Using Onyx.set in setApprovalWorkflow is mandatory to fix the Android native bug.
Not sure that's the case based on my testings. Can you double check?
@s77rt We need set
to fix this bug completely. And my alternate solution is complete. Let me explain my alternate solution.
clearApprovalWorkflow
from WorkspaceWorkflowsApprovalsExpensesFromPage
and only use goBack() as mentioned in my main proposal.setApprovalWorkflow
.Note: If we use a set, we don't need to add clearApprovalWorkflow
anywhere, because each time the set is called, it will reset the ONYXKEYS.APPROVAL_WORKFLOW
and I believe my alternate proposal is different from @nkdengineer's proposal
@garrettmknight, @s77rt, @stitesExpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
@stitesExpensify I think we can go ahead and assign @Nodebrute (proposal)
📣 @Nodebrute 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!
Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑💻 Keep in mind: Code of Conduct | Contributing 📖
Reviewing
label has been removed, please complete the "BugZero Checklist".
The solution for this issue has been :rocket: deployed to production :rocket: in version 9.0.48-2 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2024-10-22. :confetti_ball:
For reference, here are some details about the assignees on this issue:
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
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.43-1 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: N/A Issue reported by: Applause - Internal Team
Action Performed:
Expected Result:
While tapping add approval workflow or on tapping app back button "No members to display " page must not be shown
Actual Result:
In Android, tapping add approval workflow " No members to display " shown briefly but in mweb while tapping back button No members to display " page is shown
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
https://github.com/user-attachments/assets/116d6380-9b59-46f2-907f-f5f120126219
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @garrettmknight