-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Improve cancelling money in a different currency offline #13329
Conversation
38ae98f
to
7038110
Compare
129c34f
to
c4492d2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is quite rather non-trivial logic right there 😄
|
||
const shouldShowIOUPreview = ( | ||
props.isMostRecentIOUReportAction && Boolean(props.action.originalMessage.IOUReportID) | ||
) || props.action.originalMessage.type === 'pay'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isnt there some const for the pay
type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah will update.
<IOUPreview | ||
pendingAction={lodashGet(props.action, 'pendingAction', null)} | ||
iouReportID={props.action.originalMessage.IOUReportID.toString()} | ||
chatReportID={props.chatReportID} | ||
shouldShowPendingConversionMessage={shouldShowPendingConversionMessage} | ||
onPayButtonPressed={launchDetailsModal} | ||
onPreviewPressed={launchDetailsModal} | ||
containerStyles={[ | ||
styles.cursorPointer, | ||
props.isHovered | ||
? styles.iouPreviewBoxHover | ||
: undefined, | ||
]} | ||
isHovered={props.isHovered} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm I think this is the correct indentation, my editor auto indents the file as per eslint rules. I'll double check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I am wrong, definitely not as smart as IDE 😄
src/libs/IOUUtils.js
Outdated
@@ -63,7 +64,73 @@ function updateIOUOwnerAndTotal(iouReport, actorEmail, amount, currency, type = | |||
return iouReportUpdate; | |||
} | |||
|
|||
/** | |||
* Returns the list of IOU actions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a bit more context for this method would be useful.
Co-authored-by: Vit Horacek <36083550+mountiny@users.noreply.github.com>
Comments didn't help? 😕 |
Nono, I get it and how it works, but it is definitely not as easy as we would hope, especially for someone who does not have broader understanding of the IOU flow. |
This is solving more than just the issue mentioned here. I've added these improvements:
Screen.Recording.2022-12-05.at.14.36.25.movBut yes..I'm definitely open to suggestions to make this more straightforward! |
src/libs/IOUUtils.js
Outdated
const areAllRequestsInDifferentCurrencyCancelled = _.every( | ||
pendingCancelledRequestsInDifferentCurrency, | ||
requestTransactionID => _.contains(pendingRequestsInDifferentCurrency, requestTransactionID), | ||
); | ||
if (areAllRequestsInDifferentCurrencyCancelled) { | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could simplify this by calling underscore intersection on this https://underscorejs.org/#intersection such that if pendingCancelledRequestsInDifferentCurrency intersection pendingRequestsInDifferentCurrency length === pendingCancelledRequestsInDifferentCurrency.length that means it is proper subset hence the same.
Personally that is a bit easier but i like Venn diagrams so that might be why :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I simplified this even more by simply checking if both arrays are identical :D.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e voila
9168f88
to
966e018
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some minor comments.
@@ -30,9 +34,21 @@ const propTypes = { | |||
hasOutstandingIOU: PropTypes.bool.isRequired, | |||
}), | |||
|
|||
/** IOU report data object */ | |||
iouReport: PropTypes.shape({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qq: We have iouReportPropTypes
in pages/iouReportPropTypes
. Any specific reason we're creating a new PropTypes.shape
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I copied this from IOUAction
and the good thing is that is shows just what we need to use from the object, in this case only currency
is needed. But I'm happy to change this.
/** Whether the IOU is hovered so we can modify its style */ | ||
isHovered: PropTypes.bool, | ||
|
||
network: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qq: again we have networkPropTypes
defined, so any specific reason we're defining again instead of importing?
src/libs/IOUUtils.js
Outdated
function getIOUReportActions(reportActions, iouReport, type = '', pendingAction = '', filterRequestsInDifferentCurrency = false) { | ||
return _.chain(reportActions) | ||
.filter(action => action.originalMessage | ||
&& action.actionName === 'IOU' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we pick this from CONST
? May be REPORT.ACTIONS.TYPE.IOU
?
@youssef-lr Can you also update the Author checklist after fixing the comments? We also need to update the screenshots along with the author checklist. I can only then fill the reviewer checklist. Meanwhile I'll start testing as the core logic seems to be looking good. |
tests/unit/IOUUtilsTest.js
Outdated
|
||
// Default is to create requests offline, if this is specified then we need to remove the pendingAction | ||
if (isOnline) { | ||
moneyRequestAction = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we do moneyRequestAction.pendingAction = null
or if we want to delete the key then delete moneyReportAction.pendingAction
? Any specific reason we are copying it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah totally, will update. It's just a habit of mine to do immutable stuff 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aaah, I see. It's fine then I guess.
tests/unit/IOUUtilsTest.js
Outdated
expect(IOUUtils.isIOUReportPendingCurrencyConversion(reportActions, iouReport)).toBe(false); | ||
}); | ||
|
||
test('Cancelling a request made online while wxe have on made offline will show the preview', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test('Cancelling a request made online while wxe have on made offline will show the preview', () => { | |
test('Cancelling a request made online while we have one made offline will show the pending conversion message', () => { |
tests/unit/IOUUtilsTest.js
Outdated
expect(IOUUtils.isIOUReportPendingCurrencyConversion(reportActions, iouReport)).toBe(true); | ||
}); | ||
|
||
test('Cancelling a request offline in the report\'s currency when we have requests in a different currency does not show the pending ui', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test('Cancelling a request offline in the report\'s currency when we have requests in a different currency does not show the pending ui', () => { | |
test('Cancelling a request offline in the report\'s currency when we have requests in a different currency does not show the pending conversion message', () => { |
tests/unit/IOUUtilsTest.js
Outdated
}); | ||
|
||
describe('isIOUReportPendingCurrencyConversion', () => { | ||
test('Requesting money offline in a different currency shows the IOUReport as pending', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test description doesn't seem consistent with other descriptions, please try to keep it consistent.
Requesting money offline in a different currency will show the pending conversion message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good mostly; great work with this PR.
Updated! Working on screen recordings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@youssef-lr nice job, havent had time to test but left couple of NABs related to comments. Would you be able to also leave some short info int he details section?
@mananjadhav Will you be able to complete the reviewer's checklist along with Youssef working on the authors list? 🙇
Co-authored-by: Vit Horacek <36083550+mountiny@users.noreply.github.com>
Reviewer Checklist
Screenshots/VideosWebweb-offline-multicurrency-iou.movMobile Web - ChromeMobile Web - SafariDesktopdesktop-offline-multicurrency-iou.moviOSios-offline-multicurrency-iou.movAndroidandroid-offline-multicurrency-iou.mov@mountiny @techievivek I did start reviewing and testing in parallel. I was able to test this in all platforms except mobile web due to the IP issue! Can I get some help here? Also @youssef-lr screencasts for platforms excluding Web are pending. Can you please update them? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @mananjadhav
@mountiny @techievivek I did start reviewing and testing in parallel. I was able to test this in all platforms except mobile web due to the IP issue! Can I get some help here?
Also @youssef-lr screencasts for platforms excluding Web are pending. Can you please update them?
@youssef-lr Would you be able to update the details section and provide videos for this one so we can merge 🙇 Thanks!
On it! |
@mountiny added screen recordings for all platforms as well as updated the details section. |
Gonna look into this later tonight or tomorrow, sorry a bit run out of time. Can you merge main in after the reportActionID changes as well to confirm that works fine? the PR author checklist seems to be failing too @youssef-lr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @youssef-lr and @mananjadhav
Issue for payment is here #14015
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to production by @luacmartins in version: 1.2.49-0 🚀
|
This PR caused a regression. #14355 |
I am tagging this PR to highlight an issue fixed here. All conditions in ternary expressions or left-hand operands on conditional renders, should be boolean. This PR is one of the PRs that uses conditional render with string operands, hence I am tagging it here for the contributors to check. We've also updated the item in the checklist with this PR to avoid this issue in the future. |
Details
This PR improves the experience of cancelling money offline in a different currency. Since we cannot update the total while we're offline, as the currency conversion happens in the server, we can now let the user now that the total of the IOU is not final until they're back online.
Fixed Issues
$ https://github.com/Expensify/Expensify/issues/245284
$ #14015
Tests
Offline tests
Request Money - multiple currencies (offline)
Cancelling money requests - multiple currencies (offline)
QA Steps
Request Money - multiple currencies (offline)
Cancelling money requests - multiple currencies (offline)
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.Screenshots/Videos
Web
Screen.Recording.2023-01-02.at.15.20.12.mov
Mobile Web - Chrome
chrome.android.-.Screen.Recording.2023-01-03.at.22.47.18.mov
Mobile Web - Safari
safari.ios.-.RPReplay_Final1672781322.MP4
Desktop
desktop.-.Screen.Recording.2023-01-03.at.21.37.34.mov
iOS
ios.-.Screen.Recording.2023-01-03.at.22.24.34.mov
Android
android.-.Screen.Recording.2023-01-03.at.22.38.30.mov