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

[CP Stag] Add GBR to pending wallet reports & update perview for 1:1 reports #30090

Merged
merged 14 commits into from
Oct 23, 2023
Merged
4 changes: 3 additions & 1 deletion src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,9 @@ function getLastMessageTextForReport(report) {
reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE &&
ReportActionUtils.isMoneyRequestAction(reportAction),
);
lastMessageTextFromReport = ReportUtils.getReportPreviewMessage(iouReport, lastIOUMoneyReport, true);
// Weather parent report is a 1:1 report
b4s36t4 marked this conversation as resolved.
Show resolved Hide resolved
const isChatReport = ReportUtils.isChatReport(report);
techievivek marked this conversation as resolved.
Show resolved Hide resolved
b4s36t4 marked this conversation as resolved.
Show resolved Hide resolved
lastMessageTextFromReport = ReportUtils.getReportPreviewMessage(iouReport, lastIOUMoneyReport, true, isChatReport);
} else if (ReportActionUtils.isDeletedParentAction(lastReportAction) && ReportUtils.isChatReport(report)) {
lastMessageTextFromReport = ReportUtils.getDeletedParentActionMessageForChatReport(lastReportAction);
} else if (ReportActionUtils.isModifiedExpenseAction(lastReportAction)) {
Expand Down
13 changes: 8 additions & 5 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,15 @@ function sortReportsByLastRead(reports) {
* Whether the Money Request report is settled
*
* @param {String} reportID
* @param {Boolean} isReportFromChat
* @returns {Boolean}
*/
function isSettled(reportID) {
function isSettled(reportID, isReportFromChat) {
techievivek marked this conversation as resolved.
Show resolved Hide resolved
if (!allReports) {
return false;
}
const report = allReports[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`] || {};
if ((typeof report === 'object' && Object.keys(report).length === 0) || report.isWaitingOnBankAccount) {
if ((typeof report === 'object' && Object.keys(report).length === 0) || (report.isWaitingOnBankAccount && !isReportFromChat)) {
return false;
}

Expand Down Expand Up @@ -1295,7 +1296,8 @@ function isWaitingForIOUActionFromCurrentUser(report) {
}

// Money request waiting for current user to add their credit bank account
if (report.hasOutstandingIOU && report.ownerAccountID === currentUserAccountID && report.isWaitingOnBankAccount) {
// hasOutstandingIOU will be false if the user paid, but isWaitingOnBankAccount will be true if user don't have a wallet setup
b4s36t4 marked this conversation as resolved.
Show resolved Hide resolved
if ((report.hasOutstandingIOU || report.isWaitingOnBankAccount) && report.ownerAccountID === currentUserAccountID) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This condition is still wrong. It causes regression above ^

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so, I removed it and tested it still shows.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not seeing GBR after reverting this condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@situchan I think that dot is intentional, it's not showing in main (tested) because the condition is wrong (the RCA for GBR bug). Maybe you're trying in a new account.

// Money request waiting for current user to add their credit bank account

This feels like intentional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not seeing GBR after reverting this condition

Means report.hasOutstandingIOU && report.ownerAccountID === currentUserAccountID this would be the conditon right?!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Kapture.2023-10-23.at.18.21.43.mp4

this is OP for me.

Copy link
Contributor

Choose a reason for hiding this comment

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

you haven't fully reverted code.
report.isWaitingOnBankAccount is missing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm fixing it as per the comment in slack. Only show GBR when payee Paid it (no outstanding)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@situchan Fixed, Can you please check?

return true;
}

Expand Down Expand Up @@ -1615,9 +1617,10 @@ function getTransactionReportName(reportAction) {
* @param {Object} report
* @param {Object} [reportAction={}] This can be either a report preview action or the IOU action
* @param {Boolean} [shouldConsiderReceiptBeingScanned=false]
* @param {Boolean} isReportFromChat If the report is from 1:1 chat
* @returns {String}
*/
function getReportPreviewMessage(report, reportAction = {}, shouldConsiderReceiptBeingScanned = false) {
function getReportPreviewMessage(report, reportAction = {}, shouldConsiderReceiptBeingScanned = false, isReportFromChat = false) {
const reportActionMessage = lodashGet(reportAction, 'message[0].html', '');

if (_.isEmpty(report) || !report.reportID) {
Expand Down Expand Up @@ -1656,7 +1659,7 @@ function getReportPreviewMessage(report, reportAction = {}, shouldConsiderReceip
}
}

if (isSettled(report.reportID)) {
if (isSettled(report.reportID, isReportFromChat)) {
// A settled report preview message can come in three formats "paid ... elsewhere" or "paid ... with Expensify"
let translatePhraseKey = 'iou.paidElsewhereWithAmount';
if (
Expand Down
Loading