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

[TS migration] Migrate 'Report' page to TypeScript #35566

Merged
merged 40 commits into from
Mar 11, 2024

Conversation

VickyStash
Copy link
Contributor

@VickyStash VickyStash commented Feb 1, 2024

Details

[TS migration] Migrate 'Report' page to TypeScript

Fixed Issues

$ #25216
PROPOSAL: N/A

Tests

  • Verify that no errors appear in the JS console

Part 1

  1. Open the app, log in
  2. Open the chat with User B, make sure loading skeleton looks as expected
  3. Send simple text message, add reaction to this message
  4. Send multiline text message and create a message in thread, go back to the chat
  5. Update the message, delete the message
  6. Add attachment, make sure attachment loading and then the message looks as expected
  7. Assign a task. Open it, complete and incomplete -> in the header tap on three dots menu -> Delete -> approve deletion, make sure it works as expected.
  8. Send money, make sure the message looks okay, tap on it -> check that send money request chat looks ok.
  9. Request money, make sure the message looks okay, tap on it -> check that send money request chat looks ok.
  10. In the chat with User B tap on the chat header user name, make sure profile info is open
  11. In the chat header tap on the three dots menu -> pin chat, make sure pin works as expected
  12. Open the app from User B, send several messages
  13. From the User A scroll chat with user B to the top, you should see New Messages float button, tap on it -> the screen should be scrolled down, the button should disappear.

Part 2

  1. Open the app, log in
  2. Create Money Request to any user and open it.
  3. Click 3-dot menu > Hold request
  4. Enter a reason and save it
  5. Click 3-dot menu > UnHold request
  6. There are should be two system messages of hold and unhold of the request, make sure they look as expected.
  7. Click 3-dot menu -> Delete Request, make sure the request is successfully deleted.
  8. Open an existing regular room or create a new one.
  9. Tap on the description in the header -> description update screen should appear.
  10. Update description and save it. Make sure the description is updated and the message about it has appeared.
  11. Open any workspace admin chat. Tap on the description in the header -> description update screen should appear.
  12. Update description and save it. Make sure the description is updated and the message about it has appeared.
  13. Go to the workspace settings of which the workspace admins chat is open.
  14. Update workspace avatar. Go back to chats and make sure workspace avatar got updated.

Offline tests

Part 1 Steps 1-12 and Part 2 from the Tests section.
Make sure it works the same was as before the migration.

QA Steps

  • Verify that no errors appear in the JS console

Same as in the Tests section.

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
android1.mp4
Android: mWeb Chrome
android_web1.mp4
iOS: Native
ios1.mp4
iOS: mWeb Safari
ios_web_1.mp4
ios_web_2.mp4
MacOS: Chrome / Safari
web1.mp4
MacOS: Desktop
desktop1.mp4

@@ -37,38 +31,36 @@ function FloatingMessageCounter(props) {
const show = useCallback(() => {
Animated.spring(translateY, {
toValue: MARKER_ACTIVE_TRANSLATE_Y,
duration: 80,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was removed, because duration doesn't exist in spring animation config

return false;
}

if (newProps.isComposerFullSize !== oldProps.isComposerFullSize) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

isComposerFullSize wasn't used anymore in the component

Comment on lines -309 to -342
if (lodashGet(newProps, 'policy.avatar') !== lodashGet(oldProps, 'policy.avatar')) {
return false;
}

if (lodashGet(newProps, 'policy.name') !== lodashGet(oldProps, 'policy.name')) {
return false;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this component, policy was used to pass it to ReportActionsList. But it wasn't used inside ReportActionsList.

viewportOffsetTop,
isComposerFullSize,
errors,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

errors were used in hook dependency only, I wasn't able to find the source of this param as well, so I decided to remove it. If you have any thoughts - let me know

childManagerAccountID: reportAction.childManagerAccountID,
childMoneyRequestCount: reportAction.childMoneyRequestCount,
}),
const action: ReportAction = useMemo(
Copy link
Contributor

Choose a reason for hiding this comment

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

itsnt better to type it as Partial<ReportAction> ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It has all of the required ReportAction fields, so maybe it's better to leave it as ReportAction type

Copy link
Contributor

Choose a reason for hiding this comment

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

But why do we still need the as ReportAction assertion below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since ReportAction is a type of ReportActionBase & OriginalMessage, where OriginalMessage is a union, TS gives the error without the assertion:
image

src/pages/home/HeaderView.tsx Outdated Show resolved Hide resolved
src/pages/home/HeaderView.tsx Outdated Show resolved Hide resolved
@VickyStash
Copy link
Contributor Author

I've found a navigation issue during the testing, should be fixed with this PR

# Conflicts:
#	src/pages/home/HeaderView.tsx
#	src/pages/home/ReportScreen.tsx
# Conflicts:
#	src/components/MoneyReportHeader.tsx
@VickyStash
Copy link
Contributor Author

Note: I'll be OOO Feb 10 - Feb 18 🌴

# Conflicts:
#	src/libs/OnyxSelectors/reportWithoutHasDraftSelector.ts
#	src/pages/home/HeaderView.tsx
#	src/pages/home/ReportScreen.tsx
#	src/pages/home/report/ReportActionsList.tsx
#	src/pages/home/report/ReportActionsView.tsx
src/components/ScreenWrapper.tsx Show resolved Hide resolved
src/libs/OnyxSelectors/reportWithoutHasDraftSelector.ts Outdated Show resolved Hide resolved
src/pages/home/ReportScreen.tsx Show resolved Hide resolved
childManagerAccountID: reportAction.childManagerAccountID,
childMoneyRequestCount: reportAction.childMoneyRequestCount,
}),
const action: ReportAction = useMemo(
Copy link
Contributor

Choose a reason for hiding this comment

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

But why do we still need the as ReportAction assertion below?

isLoadingInitialReportActions={props.isLoadingInitialReportActions}
isLoadingOlderReportActions={props.isLoadingOlderReportActions}
isLoadingNewerReportActions={props.isLoadingNewerReportActions}
policy={props.policy}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this prop removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Though policy was mentioned in ReportActionsList props it wasn't used there.

@VickyStash
Copy link
Contributor Author

@puneetlath It looks like you got assigned to the issue related to this PR, will you be able to take a look at it?

Copy link
Contributor

@puneetlath puneetlath left a comment

Choose a reason for hiding this comment

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

Just a couple comments. Also, based on the code changes I see, can we add to the QA testing:

  • deleting a transaction
  • holding/un-holding a request
  • editing a room description (in a regular room and a workspace chat)

@@ -79,6 +80,9 @@ type PersonalDetails = OnyxCommon.OnyxValueWithOfflineFeedback<{

/** Status of the current user from their personal details */
status?: Status;

/** Chat report with assignee of task */
assigneeChatReport?: Report;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't follow why this is part of the PersonalDetails type. When is this used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It used in this part of the code, which added in this PR.

So assignee has PersonalDetails type and it tries to access assignee.assigneeChatReport.

 let assignee: OnyxTypes.PersonalDetails | EmptyObject = {};
if (email) {
    assignee = Object.values(allPersonalDetails).find((value) => value?.login === email) ?? {};
}
Task.createTaskAndNavigate(report.reportID, title, '', assignee?.login ?? '', assignee.accountID, assignee.assigneeChatReport, report.policyID);

But at the same time I've tried to create several tasks this way, and all of the time assignee.assigneeChatReport was undefined, so maybe we can just get rid of it. Though I'm not sure if this PR is a good place for that, cause it's already kind of complex.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, agreed, let's not do it here. Would you mind opening a separate issue to clean that up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@puneetlath Yeah, I'm okay to do that 👌

src/pages/home/ReportScreen.tsx Show resolved Hide resolved
src/pages/home/ReportScreen.tsx Show resolved Hide resolved
src/pages/home/ReportScreen.tsx Show resolved Hide resolved
# Conflicts:
#	src/pages/home/report/ReportActionsView.tsx
@VickyStash
Copy link
Contributor Author

VickyStash commented Mar 7, 2024

Recordings for additional test steps:

Android: Native
ANDROID1.mp4
Android: mWeb Chrome
ANDROID_WEB11.mp4
ANDROID_WEB21.mp4
iOS: Native
IOS_PT1.mp4
iOS: mWeb Safari
IOS_WEB_PT1.mp4
MacOS: Chrome / Safari
WEB_PT1.mp4
MacOS: Desktop
DESKTOP_PT1.mp4

# Conflicts:
#	src/libs/OnyxSelectors/reportWithoutHasDraftSelector.ts
puneetlath
puneetlath previously approved these changes Mar 9, 2024
Copy link
Contributor

@puneetlath puneetlath left a comment

Choose a reason for hiding this comment

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

Thanks for your thorough work on this. Let's see if we can get it through without regressions 😅

Also, you have conflicts, but if you ping me on Monday morning after you fix them I can merge. I'm on US east coast time.

# Conflicts:
#	src/pages/home/ReportScreen.tsx
#	src/pages/home/report/ReportActionsList.tsx
#	src/pages/home/report/ReportActionsView.tsx
@VickyStash
Copy link
Contributor Author

@puneetlath Conflicts are resolved!

@puneetlath puneetlath merged commit 59ac113 into Expensify:main Mar 11, 2024
17 checks passed
Copy link

melvin-bot bot commented Mar 11, 2024

@puneetlath looks like this was merged without a test passing. Please add a note explaining why this was done and remove the Emergency label if this is not an emergency.

@melvin-bot melvin-bot bot added the Emergency label Mar 11, 2024
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@puneetlath
Copy link
Contributor

All tests had passed when I merged.

@puneetlath
Copy link
Contributor

@VickyStash please link the personal details issue here once you've created it

@VickyStash
Copy link
Contributor Author

@puneetlath Here is created issue 👌

lastMentionedTime: reportProp.lastMentionedTime,
(): OnyxTypes.Report => ({
lastReadTime: reportProp?.lastReadTime,
reportID: reportProp?.reportID ?? '',
Copy link
Contributor

Choose a reason for hiding this comment

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

@VickyStash Is this change intentional or just to fix TS error? It's possible that reportID can be undefined.
We're blocked here because of this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aimane-chnaif It was done to follow TS typing

const onListLayout = useCallback((e) => {
setListHeight((prev) => lodashGet(e, 'nativeEvent.layout.height', prev));
const onListLayout = useCallback((event: LayoutChangeEvent) => {
setListHeight((prev) => event.nativeEvent.layout.height ?? prev);
Copy link
Contributor

Choose a reason for hiding this comment

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

Android app crashes on this line

android.mov
Screenshot 2024-03-12 at 4 11 05 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aimane-chnaif thank you, I'll raise a follow-up PR

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/puneetlath in version: 1.4.51-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/luacmartins in version: 1.4.51-3 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants