From a7c74d0e8042737005eff31f08591682ba7c7715 Mon Sep 17 00:00:00 2001 From: Yauheni Date: Mon, 1 Apr 2024 18:22:01 +0200 Subject: [PATCH 1/4] Fix bug with Workspace avatar next to request shortcut does not update when it is changed --- .../SidebarScreen/FloatingActionButtonAndPopover.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js index be8a43b1a483..380a50da287b 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js @@ -37,6 +37,8 @@ const policySelector = (policy) => role: policy.role, isPolicyExpenseChatEnabled: policy.isPolicyExpenseChatEnabled, pendingAction: policy.pendingAction, + avatar: policy.avatar, + name: policy.name, }; const getQuickActionIcon = (action) => { @@ -153,13 +155,16 @@ function FloatingActionButtonAndPopover(props) { const quickActionReport = useMemo(() => (props.quickAction ? ReportUtils.getReport(props.quickAction.chatReportID) : 0), [props.quickAction]); + const policy = props.allPolicies ? props.allPolicies[`${ONYXKEYS.COLLECTION.POLICY}${quickActionReport.policyID}`] : undefined; + const quickActionAvatars = useMemo(() => { if (quickActionReport) { const avatars = ReportUtils.getIcons(quickActionReport, props.personalDetails); return avatars.length <= 1 || ReportUtils.isPolicyExpenseChat(quickActionReport) ? avatars : _.filter(avatars, (avatar) => avatar.id !== props.session.accountID); } return []; - }, [props.personalDetails, props.session.accountID, quickActionReport]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [props.personalDetails, props.session.accountID, quickActionReport, policy]); const quickActionTitle = useMemo(() => { const titleKey = getQuickActionTitle(props.quickAction && props.quickAction.action); From b5bfe75d8cabfd34462abc128c3b8e447cb4a684 Mon Sep 17 00:00:00 2001 From: Yauheni Date: Thu, 4 Apr 2024 16:16:15 +0200 Subject: [PATCH 2/4] Fix comments --- .../sidebar/SidebarScreen/FloatingActionButtonAndPopover.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js index 380a50da287b..548acfc5d918 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js @@ -155,7 +155,7 @@ function FloatingActionButtonAndPopover(props) { const quickActionReport = useMemo(() => (props.quickAction ? ReportUtils.getReport(props.quickAction.chatReportID) : 0), [props.quickAction]); - const policy = props.allPolicies ? props.allPolicies[`${ONYXKEYS.COLLECTION.POLICY}${quickActionReport.policyID}`] : undefined; + const quickActionPolicy = props.allPolicies ? props.allPolicies[`${ONYXKEYS.COLLECTION.POLICY}${quickActionReport.policyID}`] : undefined; const quickActionAvatars = useMemo(() => { if (quickActionReport) { @@ -163,8 +163,9 @@ function FloatingActionButtonAndPopover(props) { return avatars.length <= 1 || ReportUtils.isPolicyExpenseChat(quickActionReport) ? avatars : _.filter(avatars, (avatar) => avatar.id !== props.session.accountID); } return []; + // We added police depending on the fact that if the workspace changes, we would see these changes on Shortcut too // eslint-disable-next-line react-hooks/exhaustive-deps - }, [props.personalDetails, props.session.accountID, quickActionReport, policy]); + }, [props.personalDetails, props.session.accountID, quickActionReport, quickActionPolicy]); const quickActionTitle = useMemo(() => { const titleKey = getQuickActionTitle(props.quickAction && props.quickAction.action); From 224ea3a140a01e3b4e09a2dcb207090e620509dd Mon Sep 17 00:00:00 2001 From: Yauheni Date: Thu, 4 Apr 2024 16:17:50 +0200 Subject: [PATCH 3/4] Fix comments x3 --- .../sidebar/SidebarScreen/FloatingActionButtonAndPopover.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js index 548acfc5d918..8262d0b6ca29 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js @@ -163,7 +163,7 @@ function FloatingActionButtonAndPopover(props) { return avatars.length <= 1 || ReportUtils.isPolicyExpenseChat(quickActionReport) ? avatars : _.filter(avatars, (avatar) => avatar.id !== props.session.accountID); } return []; - // We added police depending on the fact that if the workspace changes, we would see these changes on Shortcut too + // We added police depending on the fact that if the workspace changes, we would see these changes on Shortcut too // eslint-disable-next-line react-hooks/exhaustive-deps }, [props.personalDetails, props.session.accountID, quickActionReport, quickActionPolicy]); From 9adb9ef614bad65743dc544aaa6f83608211e94c Mon Sep 17 00:00:00 2001 From: Yauheni Date: Thu, 4 Apr 2024 16:42:26 +0200 Subject: [PATCH 4/4] Fix comments x2 --- .../sidebar/SidebarScreen/FloatingActionButtonAndPopover.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js index 8262d0b6ca29..21f12a543cc7 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js @@ -163,7 +163,7 @@ function FloatingActionButtonAndPopover(props) { return avatars.length <= 1 || ReportUtils.isPolicyExpenseChat(quickActionReport) ? avatars : _.filter(avatars, (avatar) => avatar.id !== props.session.accountID); } return []; - // We added police depending on the fact that if the workspace changes, we would see these changes on Shortcut too + // Policy is needed as a dependency in order to update the shortcut details when the workspace changes // eslint-disable-next-line react-hooks/exhaustive-deps }, [props.personalDetails, props.session.accountID, quickActionReport, quickActionPolicy]);