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

Shortcut - Workspace avatar next to request shortcut does not update when it is changed #39368

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -153,13 +155,17 @@ function FloatingActionButtonAndPopover(props) {

const quickActionReport = useMemo(() => (props.quickAction ? ReportUtils.getReport(props.quickAction.chatReportID) : 0), [props.quickAction]);

const quickActionPolicy = 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]);
// 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a brief explanatory comment here, so future visitors know why we've included policy as a dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done )

}, [props.personalDetails, props.session.accountID, quickActionReport, quickActionPolicy]);

const quickActionTitle = useMemo(() => {
const titleKey = getQuickActionTitle(props.quickAction && props.quickAction.action);
Expand Down
Loading