Skip to content

Commit

Permalink
Merge pull request #25534 from tienifr/fix/24420
Browse files Browse the repository at this point in the history
fix: 24420 Timezone message for assignee disappears
  • Loading branch information
youssef-lr authored Sep 1, 2023
2 parents db30142 + 2192f3c commit bcf864c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
20 changes: 16 additions & 4 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,18 @@ function hasAutomatedExpensifyAccountIDs(accountIDs) {
return _.intersection(accountIDs, CONST.EXPENSIFY_ACCOUNT_IDS).length > 0;
}

/**
* @param {Object} report
* @param {Number} currentLoginAccountID
* @returns {Array}
*/
function getReportRecipientAccountIDs(report, currentLoginAccountID) {
const participantAccountIDs = isTaskReport(report) ? [report.managerID] : lodashGet(report, 'participantAccountIDs');
const reportParticipants = _.without(participantAccountIDs, currentLoginAccountID);
const participantsWithoutExpensifyAccountIDs = _.difference(reportParticipants, CONST.EXPENSIFY_ACCOUNT_IDS);
return participantsWithoutExpensifyAccountIDs;
}

/**
* Whether the time row should be shown for a report.
* @param {Array<Object>} personalDetails
Expand All @@ -827,10 +839,9 @@ function hasAutomatedExpensifyAccountIDs(accountIDs) {
* @return {Boolean}
*/
function canShowReportRecipientLocalTime(personalDetails, report, accountID) {
const reportParticipants = _.without(lodashGet(report, 'participantAccountIDs', []), accountID);
const participantsWithoutExpensifyAccountIDs = _.difference(reportParticipants, CONST.EXPENSIFY_ACCOUNT_IDS);
const hasMultipleParticipants = participantsWithoutExpensifyAccountIDs.length > 1;
const reportRecipient = personalDetails[participantsWithoutExpensifyAccountIDs[0]];
const reportRecipientAccountIDs = getReportRecipientAccountIDs(report, accountID);
const hasMultipleParticipants = reportRecipientAccountIDs.length > 1;
const reportRecipient = personalDetails[reportRecipientAccountIDs[0]];
const reportRecipientTimezone = lodashGet(reportRecipient, 'timezone', CONST.DEFAULT_TIME_ZONE);
const isReportParticipantValidated = lodashGet(reportRecipient, 'validated', false);
return Boolean(
Expand Down Expand Up @@ -3572,6 +3583,7 @@ export {
shouldDisableSettings,
shouldDisableRename,
hasSingleParticipant,
getReportRecipientAccountIDs,
isOneOnOneChat,
getTransactionReportName,
getTransactionDetails,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ function ReportActionCompose({
() => _.without(lodashGet(report, 'participantAccountIDs', []), currentUserPersonalDetails.accountID),
[currentUserPersonalDetails.accountID, report],
);
const participantsWithoutExpensifyAccountIDs = useMemo(() => _.difference(reportParticipantIDs, CONST.EXPENSIFY_ACCOUNT_IDS), [reportParticipantIDs]);

const shouldShowReportRecipientLocalTime = useMemo(
() => ReportUtils.canShowReportRecipientLocalTime(personalDetails, report, currentUserPersonalDetails.accountID) && !isComposerFullSize,
Expand Down Expand Up @@ -316,7 +315,8 @@ function ReportActionCompose({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const reportRecipient = personalDetails[participantsWithoutExpensifyAccountIDs[0]];
const reportRecipientAcountIDs = ReportUtils.getReportRecipientAccountIDs(report, currentUserPersonalDetails.accountID);
const reportRecipient = personalDetails[reportRecipientAcountIDs[0]];
const shouldUseFocusedColor = !isBlockedFromConcierge && !disabled && isFocused;

const hasReportRecipient = _.isObject(reportRecipient) && !_.isEmpty(reportRecipient);
Expand Down

0 comments on commit bcf864c

Please sign in to comment.