Skip to content

Commit

Permalink
Merge pull request #33398 from tienifr/fix/32924
Browse files Browse the repository at this point in the history
fix: Green dot does not appear in LHN when the request is created in workspace chat
  • Loading branch information
nkuoch authored Jan 26, 2024
2 parents 675b2c3 + b118e62 commit 3f702b7
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,29 @@ function getReceiptError(receipt, filename, isScanRequest = true) {
: ErrorUtils.getMicroSecondOnyxErrorObject({error: CONST.IOU.RECEIPT_ERROR, source: receipt.source, filename});
}

/**
* Return the object to update hasOutstandingChildRequest
* @param {Object} [policy]
* @param {Boolean} needsToBeManuallySubmitted
* @returns {Object}
*/
function getOutstandingChildRequest(policy, needsToBeManuallySubmitted) {
if (!needsToBeManuallySubmitted) {
return {
hasOutstandingChildRequest: false,
};
}

if (PolicyUtils.isPolicyAdmin(policy)) {
return {
hasOutstandingChildRequest: true,
};
}

// We don't need to update hasOutstandingChildRequest in this case
return {};
}

/**
* Builds the Onyx data for a money request.
*
Expand All @@ -329,7 +352,7 @@ function getReceiptError(receipt, filename, isScanRequest = true) {
* @param {Object} policy - May be undefined, an empty object, or an object matching the Policy type (src/types/onyx/Policy.ts)
* @param {Array} policyTags
* @param {Array} policyCategories
* @param {Boolean} hasOutstandingChildRequest
* @param {Boolean} needsToBeManuallySubmitted
* @returns {Array} - An array containing the optimistic data, success data, and failure data.
*/
function buildOnyxDataForMoneyRequest(
Expand All @@ -348,9 +371,10 @@ function buildOnyxDataForMoneyRequest(
policy,
policyTags,
policyCategories,
hasOutstandingChildRequest = false,
needsToBeManuallySubmitted = true,
) {
const isScanRequest = TransactionUtils.isScanRequest(transaction);
const outstandingChildRequest = getOutstandingChildRequest(needsToBeManuallySubmitted, policy);
const optimisticData = [
{
// Use SET for new reports because it doesn't exist yet, is faster and we need the data to be available when we navigate to the chat page
Expand All @@ -361,7 +385,7 @@ function buildOnyxDataForMoneyRequest(
lastReadTime: DateUtils.getDBTime(),
lastMessageTranslationKey: '',
iouReportID: iouReport.reportID,
hasOutstandingChildRequest,
...outstandingChildRequest,
...(isNewChatReport ? {pendingFields: {createChat: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}} : {}),
},
},
Expand Down Expand Up @@ -506,6 +530,7 @@ function buildOnyxDataForMoneyRequest(
iouReportID: chatReport.iouReportID,
lastReadTime: chatReport.lastReadTime,
pendingFields: null,
hasOutstandingChildRequest: chatReport.hasOutstandingChildRequest,
...(isNewChatReport
? {
errorFields: {
Expand Down Expand Up @@ -687,7 +712,7 @@ function getMoneyRequestInformation(
let iouReport = isNewIOUReport ? null : allReports[`${ONYXKEYS.COLLECTION.REPORT}${chatReport.iouReportID}`];

// Check if the Scheduled Submit is enabled in case of expense report
let needsToBeManuallySubmitted = false;
let needsToBeManuallySubmitted = true;
let isFromPaidPolicy = false;
if (isPolicyExpenseChat) {
isFromPaidPolicy = PolicyUtils.isPaidGroupPolicy(policy);
Expand Down Expand Up @@ -806,10 +831,6 @@ function getMoneyRequestInformation(
}
: undefined;

// The policy expense chat should have the GBR only when its a paid policy and the scheduled submit is turned off
// so the employee has to submit to their manager manually.
const hasOutstandingChildRequest = isPolicyExpenseChat && needsToBeManuallySubmitted;

// STEP 5: Build Onyx Data
const [optimisticData, successData, failureData] = buildOnyxDataForMoneyRequest(
chatReport,
Expand All @@ -827,7 +848,7 @@ function getMoneyRequestInformation(
policy,
policyTags,
policyCategories,
hasOutstandingChildRequest,
needsToBeManuallySubmitted,
);

return {
Expand Down

0 comments on commit 3f702b7

Please sign in to comment.