Skip to content

Commit

Permalink
Merge pull request #26845 from huzaifa-99/24228-fix-user-local-time
Browse files Browse the repository at this point in the history
Show local time in money request and 1:1 chat threads
  • Loading branch information
roryabraham authored Sep 19, 2023
2 parents 6d67552 + 723b331 commit b2e29b5
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -843,8 +843,30 @@ function hasAutomatedExpensifyAccountIDs(accountIDs) {
* @returns {Array}
*/
function getReportRecipientAccountIDs(report, currentLoginAccountID) {
const participantAccountIDs = isTaskReport(report) ? [report.managerID] : lodashGet(report, 'participantAccountIDs');
const reportParticipants = _.without(participantAccountIDs, currentLoginAccountID);
let finalReport = report;
// In 1:1 chat threads, the participants will be the same as parent report. If a report is specifically a 1:1 chat thread then we will
// get parent report and use its participants array.
if (isThread(report) && !(isTaskReport(report) || isMoneyRequestReport(report))) {
const parentReport = lodashGet(allReports, [`${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID}`]);
if (hasSingleParticipant(parentReport)) {
finalReport = parentReport;
}
}

let finalParticipantAccountIDs = [];
if (isMoneyRequestReport(report)) {
// For money requests i.e the IOU (1:1 person) and Expense (1:* person) reports, use the full `initialParticipantAccountIDs` array
// and add the `ownerAccountId`. Money request reports don't add `ownerAccountId` in `participantAccountIDs` array
finalParticipantAccountIDs = _.union(lodashGet(finalReport, 'participantAccountIDs'), [report.ownerAccountID]);
} else if (isTaskReport(report)) {
// Task reports `managerID` will change when assignee is changed, in that case the old `managerID` is still present in `participantAccountIDs`
// array along with the new one. We only need the `managerID` as a participant here.
finalParticipantAccountIDs = [report.managerID];
} else {
finalParticipantAccountIDs = lodashGet(finalReport, 'participantAccountIDs');
}

const reportParticipants = _.without(finalParticipantAccountIDs, currentLoginAccountID);
const participantsWithoutExpensifyAccountIDs = _.difference(reportParticipants, CONST.EXPENSIFY_ACCOUNT_IDS);
return participantsWithoutExpensifyAccountIDs;
}
Expand Down

0 comments on commit b2e29b5

Please sign in to comment.